Documentation
¶
Index ¶
- Constants
- Variables
- func Poll(interval, deadline time.Duration, condition ConditionFunc) error
- func RevertReason(ctx context.Context, c ethClienter, tx *types.Transaction, ...) (string, error)
- func WaitSignal(cleanupFuncs ...func())
- func WaitTxReceipt(ctx context.Context, txHash common.Hash, timeout time.Duration, ...) (*types.Receipt, error)
- func WaitTxToBeMined(parentCtx context.Context, client ethClienter, tx *types.Transaction, ...) error
- type Client
- func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)
- func (etherMan *Client) CurrentNonce(ctx context.Context, account common.Address) (uint64, error)
- func (etherMan *Client) EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, ...) (uint64, error)
- func (etherMan *Client) EstimateGasBlobTx(ctx context.Context, from common.Address, to *common.Address, ...) (uint64, error)
- func (etherMan *Client) GetHeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (etherMan *Client) GetL1GasPrice(ctx context.Context) (*big.Int, error)
- func (etherMan *Client) GetLatestBlockNumber(ctx context.Context) (uint64, error)
- func (etherMan *Client) GetRevertMessage(ctx context.Context, tx *types.Transaction) (string, error)
- func (etherMan *Client) GetSuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (etherMan *Client) GetTx(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
- func (etherMan *Client) GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (etherMan *Client) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (etherMan *Client) PendingNonce(ctx context.Context, account common.Address) (uint64, error)
- func (etherMan *Client) PublicAddress() ([]common.Address, error)
- func (etherMan *Client) SendTx(ctx context.Context, tx *types.Transaction) error
- func (etherMan *Client) SignTx(ctx context.Context, sender common.Address, tx *types.Transaction) (*types.Transaction, error)
- func (etherMan *Client) SuggestedGasPrice(ctx context.Context) (*big.Int, error)
- func (etherMan *Client) WaitTxToBeMined(ctx context.Context, tx *types.Transaction, timeout time.Duration) (bool, error)
- type ConditionFunc
- type Config
- type EthereumClient
- type EthermanSigner
- type EthermanSigners
- type Wait
Constants ¶
const ( // DefaultInterval is a time interval DefaultInterval = 2 * time.Millisecond // DefaultDeadline is a time interval DefaultDeadline = 2 * time.Minute // DefaultTxMinedDeadline is a time interval DefaultTxMinedDeadline = 5 * time.Second )
Variables ¶
var ( // ErrNotFound is used when the object is not found ErrNotFound = ethereum.NotFound // ErrPrivateKeyNotFound used when the provided sender does not have a private key registered to be used ErrPrivateKeyNotFound = errors.New("can't find sender private key to sign tx") // ErrObjectIsNil used when the object is nil ErrObjectIsNil = errors.New("object is nil") )
var ( // ErrTimeoutReached is thrown when the timeout is reached and // because the condition is not matched ErrTimeoutReached = fmt.Errorf("timeout has been reached") )
Functions ¶
func Poll ¶
func Poll(interval, deadline time.Duration, condition ConditionFunc) error
Poll retries the given condition with the given interval until it succeeds or the given deadline expires.
func RevertReason ¶
func RevertReason(ctx context.Context, c ethClienter, tx *types.Transaction, blockNumber *big.Int) (string, error)
RevertReason returns the revert reason for a tx that has a receipt with failed status
func WaitSignal ¶
func WaitSignal(cleanupFuncs ...func())
WaitSignal blocks until an Interrupt or Kill signal is received, then it executes the given cleanup functions and returns.
func WaitTxReceipt ¶
func WaitTxReceipt( ctx context.Context, txHash common.Hash, timeout time.Duration, client *ethclient.Client, ) (*types.Receipt, error)
WaitTxReceipt waits until a tx receipt is available or the given timeout expires.
func WaitTxToBeMined ¶
func WaitTxToBeMined( parentCtx context.Context, client ethClienter, tx *types.Transaction, timeout time.Duration, ) error
WaitTxToBeMined waits until a tx has been mined or the given timeout expires.
Types ¶
type Client ¶
type Client struct { EthClient EthereumClient GasProviders externalGasProviders // contains filtered or unexported fields }
Client is a simple implementation of EtherMan.
func NewClient ¶
func NewClient(cfg Config, signersConfig []signertypes.SignerConfig) (*Client, error)
NewClient creates a new etherman.
func (*Client) CheckTxWasMined ¶
func (etherMan *Client) CheckTxWasMined(ctx context.Context, txHash common.Hash) (bool, *types.Receipt, error)
CheckTxWasMined check if a tx was already mined
func (*Client) CurrentNonce ¶
CurrentNonce returns the current nonce for the provided account
func (*Client) EstimateGas ¶
func (etherMan *Client) EstimateGas( ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte, ) (uint64, error)
EstimateGas returns the estimated gas for the tx
func (*Client) EstimateGasBlobTx ¶
func (etherMan *Client) EstimateGasBlobTx( ctx context.Context, from common.Address, to *common.Address, gasFeeCap *big.Int, gasTipCap *big.Int, value *big.Int, data []byte, ) (uint64, error)
EstimateGasBlobTx returns the estimated gas for the blob tx
func (*Client) GetHeaderByNumber ¶
func (etherMan *Client) GetHeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
GetHeaderByNumber returns a block header from the current canonical chain. If number is nil the latest header is returned
func (*Client) GetL1GasPrice ¶
GetL1GasPrice gets the L1 gas price from available providers
func (*Client) GetLatestBlockNumber ¶
GetLatestBlockNumber gets the latest block number from the ethereum
func (*Client) GetRevertMessage ¶
func (etherMan *Client) GetRevertMessage(ctx context.Context, tx *types.Transaction) (string, error)
GetRevertMessage tries to get a revert message of a transaction
func (*Client) GetSuggestGasTipCap ¶
GetSuggestGasTipCap retrieves the currently suggested gas tip cap after EIP-1559 for timely transaction execution.
func (*Client) GetTx ¶
func (etherMan *Client) GetTx(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
GetTx function get ethereum tx
func (*Client) GetTxReceipt ¶
func (etherMan *Client) GetTxReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
GetTxReceipt function gets ethereum tx receipt
func (*Client) HeaderByNumber ¶
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*Client) PendingNonce ¶
PendingNonce returns the pending nonce for the provided account
func (*Client) PublicAddress ¶ added in v0.2.8
PublicAddress returns the public addresses of the signers
func (*Client) SignTx ¶
func (etherMan *Client) SignTx( ctx context.Context, sender common.Address, tx *types.Transaction, ) (*types.Transaction, error)
SignTx tries to sign a transaction accordingly to the provided sender
func (*Client) SuggestedGasPrice ¶
SuggestedGasPrice returns the suggested gas price for the network at the moment Allows zero as a valid gas price
type ConditionFunc ¶
ConditionFunc is a generic function
type Config ¶
type Config struct { // URL is the URL of the Ethereum node for L1 URL string `mapstructure:"URL"` // allow that L1 gas price calculation use multiples sources MultiGasProvider bool `mapstructure:"MultiGasProvider"` // Configuration for use Etherscan as used as gas provider, basically it needs the API-KEY Etherscan etherscan.Config // L1ChainID specifies the chain ID of the network to which transactions will be sent // If set to 0, the chain ID will be fetched from the RPC endpoint L1ChainID uint64 `mapstructure:"L1ChainID"` // HTTPHeaders are the headers to be used in the HTTP requests HTTPHeaders map[string]string `mapstructure:"HTTPHeaders"` }
Config represents the configuration of the etherman
type EthereumClient ¶ added in v0.2.6
type EthereumClient interface { ethereum.ChainReader ethereum.ChainStateReader ethereum.ChainIDReader ethereum.ContractCaller ethereum.GasEstimator ethereum.GasPricer ethereum.GasPricer1559 ethereum.PendingStateReader ethereum.TransactionReader ethereum.TransactionSender bind.DeployBackend Client() *rpc.Client }
EthereumClient is an interface that combines all the ethereum client interfaces
type EthermanSigner ¶ added in v0.2.8
type EthermanSigner interface { SignTx(ctx context.Context, sender common.Address, tx *types.Transaction) (*types.Transaction, error) PublicAddress() ([]common.Address, error) }
EthermanSigner is an interface that combines all the signer interfaces
type EthermanSigners ¶ added in v0.2.8
type EthermanSigners struct {
// contains filtered or unexported fields
}
EthermanSigners is a struct that holds the signers
func NewEthermanSigners ¶ added in v0.2.8
func NewEthermanSigners(ctx context.Context, chainID uint64, config []signertypes.SignerConfig) (*EthermanSigners, error)
NewEthermanSigners creates a new instance of EthermanSigners
func (*EthermanSigners) PublicAddress ¶ added in v0.2.8
func (s *EthermanSigners) PublicAddress() ([]common.Address, error)
PublicAddress returns the public addresses of the signers
func (*EthermanSigners) SignTx ¶ added in v0.2.8
func (s *EthermanSigners) SignTx(ctx context.Context, sender common.Address, tx *types.Transaction) (*types.Transaction, error)
SignTx tries to sign a transaction accordingly to the provided sender