evm/polygon/client.go
2021-11-09 09:07:42 +04:00

31 lines
682 B
Go

package polygon
import (
"context"
"git.lehouerou.net/laurent/evm"
"github.com/pkg/errors"
)
const (
RpcUrl = "https://polygon-rpc.com"
)
type Client struct {
evm.Client
}
func NewClientWithUrl(ctx context.Context, rpcurl string, privatekey string, options ...evm.ClientOption) (*Client, error) {
ethclient, err := evm.NewClient(ctx, rpcurl, privatekey, NewTokenMapper(), options...)
if err != nil {
return nil, errors.Wrap(err, "creating ethereum client")
}
return &Client{
ethclient,
}, nil
}
func NewClient(ctx context.Context, privatekey string, options ...evm.ClientOption) (*Client, error) {
return NewClientWithUrl(ctx, RpcUrl, privatekey, options...)
}