evm/avalanche/client.go

31 lines
698 B
Go

package avalanche
import (
"context"
"git.lehouerou.net/laurent/evm"
"github.com/pkg/errors"
)
const (
RpcUrl = "https://api.avax.network/ext/bc/C/rpc"
)
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...)
}