Documentation ¶
Overview ¶
Package extethclient provides libraries for interacting with an ethereum node using a specific private key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EthClient ¶
type EthClient interface { Address() ethcommon.Address SetAddress(addr ethcommon.Address) PrivateKey() *ecdsa.PrivateKey HasPrivateKey() bool Endpoint() string Balance(ctx context.Context) (*coins.WeiAmount, error) ERC20Balance(ctx context.Context, token ethcommon.Address) (*coins.ERC20TokenAmount, error) ERC20Info(ctx context.Context, tokenAddr ethcommon.Address) (*coins.ERC20TokenInfo, error) SetGasPrice(uint64) SetGasLimit(uint64) SuggestGasPrice(ctx context.Context) (*big.Int, error) CallOpts(ctx context.Context) *bind.CallOpts TxOpts(ctx context.Context) (*bind.TransactOpts, error) ChainID() *big.Int Lock() // Lock the wallet so only one transaction runs at at time Unlock() // Unlock the wallet after a transaction is complete // transfers ETH to the given address // does not need locking, as it locks internally Transfer(ctx context.Context, to ethcommon.Address, amount *coins.WeiAmount) (ethcommon.Hash, error) WaitForReceipt(ctx context.Context, txHash ethcommon.Hash) (*ethtypes.Receipt, error) WaitForTimestamp(ctx context.Context, ts time.Time) error LatestBlockTimestamp(ctx context.Context) (time.Time, error) Close() Raw() *ethclient.Client }
EthClient provides management of a private key and other convenience functions layered on top of the go-ethereum client. You can still access the raw go-ethereum client via the Raw() method.
func CreateTestClient ¶
func CreateTestClient(t *testing.T, ethKey *ecdsa.PrivateKey) EthClient
CreateTestClient creates and extended eth client using the passed ethereum wallet key. Cleanup on test completion is handled automatically.
func NewEthClient ¶
func NewEthClient( ctx context.Context, env common.Environment, endpoint string, privKey *ecdsa.PrivateKey, ) (EthClient, error)
NewEthClient creates and returns our extended ethereum client/wallet. The passed context is only used for creation. The privKey can be nil if you are using an external signer.
Click to show internal directories.
Click to hide internal directories.