Documentation ¶
Index ¶
- func GetPublicAddressFromPrivateKey(privateKey *ecdsa.PrivateKey) (common.Address, error)
- func WrapExternalError(originalErr error, message string) error
- type EIP1559TransactionHelper
- func (eipHelper *EIP1559TransactionHelper) ContractFunctionCall(contractAddress *common.Address, contractABI abi.ABI, blockNumber *big.Int, ...) ([]interface{}, error)
- func (eipHelper *EIP1559TransactionHelper) ContractFunctionCallNoArguments(contractAddress *common.Address, contractABI abi.ABI, blockNumber *big.Int, ...) ([]interface{}, error)
- func (eipHelper *EIP1559TransactionHelper) FilterTransactionLog(txReceipt *types.Receipt, txLogs []*types.Log, filter ethereum.FilterQuery) ([]types.Log, error)
- func (eipHelper *EIP1559TransactionHelper) GetBaseFee() (*big.Int, error)
- func (eipHelper *EIP1559TransactionHelper) GetEthClient() *ethclient.Client
- func (eipHelper *EIP1559TransactionHelper) GetGasParameters(from common.Address, to *common.Address, value *big.Int, data []byte) (Gas1559Params, error)
- func (eipHelper *EIP1559TransactionHelper) GetLatestBlockNumber() (*big.Int, error)
- func (eipHelper *EIP1559TransactionHelper) GetPublicAddressFromPrivateKey(privateKey *ecdsa.PrivateKey) (common.Address, error)
- func (eipHelper *EIP1559TransactionHelper) GetRpcUrl() string
- func (eipHelper *EIP1559TransactionHelper) SendTransaction(privateKey *ecdsa.PrivateKey, to *common.Address, chainID *big.Int, ...) (receipt *types.Receipt, err error)
- type ExternalErrorWrapper
- type Gas1559Params
- type TxHelperRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPublicAddressFromPrivateKey ¶
func GetPublicAddressFromPrivateKey(privateKey *ecdsa.PrivateKey) (common.Address, error)
func WrapExternalError ¶
WrapExternalError to easily create a new error which wraps the given error.
Types ¶
type EIP1559TransactionHelper ¶
type EIP1559TransactionHelper struct {
// contains filtered or unexported fields
}
func CreateEIP1559TxHelper ¶
func CreateEIP1559TxHelper(rpcUrl string, gasTip int64, emulation bool, receiptMock types.Receipt) *EIP1559TransactionHelper
CreateEIP1559TxHelper
gasTip is optional parameter, if 0 passed, default gasTip = 2_000_000_000 is applied. However, 2_000_000_000 is too much for L2 networks, it's much bigger than L2 base fee, and when calculating total transaction cost = gasAmountNeeded * maxFeePerGas, where maxFeePerGas = 2 * baseFee + GasTipCap (https://www.blocknative.com/blog/eip-1559-fees), total gas needed (gasAmountNeeded) can be too high and unacceptable for low banks (greater than transaction net value), and lead to error "insufficient funds for gas * price + value" For L2 networks gasTip = 100_000_000 is recommended
func (*EIP1559TransactionHelper) ContractFunctionCall ¶
func (eipHelper *EIP1559TransactionHelper) ContractFunctionCall(contractAddress *common.Address, contractABI abi.ABI, blockNumber *big.Int, methodName string, args ...interface{}) ([]interface{}, error)
ContractFunctionCall calls method "methodName" in contract "contractAddress"
[READONLY] This is NOT-state-changing call
func (*EIP1559TransactionHelper) ContractFunctionCallNoArguments ¶
func (eipHelper *EIP1559TransactionHelper) ContractFunctionCallNoArguments(contractAddress *common.Address, contractABI abi.ABI, blockNumber *big.Int, methodName string) ([]interface{}, error)
ContractFunctionCallNoArguments calls method "methodName" in contract "contractAddress", suitable for methods with NO arguments
[READONLY] This is NOT-state-changing call
func (*EIP1559TransactionHelper) FilterTransactionLog ¶
func (eipHelper *EIP1559TransactionHelper) FilterTransactionLog(txReceipt *types.Receipt, txLogs []*types.Log, filter ethereum.FilterQuery) ([]types.Log, error)
FilterTransactionLog filters INDEXED (only topics) transaction logs by applying ethereum.FilterQuery filter
How filter works:
BlockHash | FromBlock | ToBlock |- are all ignored, because we expect either txReceipt OR txLogs from one specific transaction, we should not (and don't want to) iterate through blocks!
Addresses - restricts matches to events created by specific contracts, if EMPTY -> ANY address will pass, also see -> ethereum.FilterQuery
Topics - restricts matches to particular event topics, an empty element slice matches any topic, also see -> ethereum.FilterQuery
func (*EIP1559TransactionHelper) GetBaseFee ¶
func (eipHelper *EIP1559TransactionHelper) GetBaseFee() (*big.Int, error)
func (*EIP1559TransactionHelper) GetEthClient ¶
func (eipHelper *EIP1559TransactionHelper) GetEthClient() *ethclient.Client
func (*EIP1559TransactionHelper) GetGasParameters ¶
func (eipHelper *EIP1559TransactionHelper) GetGasParameters(from common.Address, to *common.Address, value *big.Int, data []byte) (Gas1559Params, error)
func (*EIP1559TransactionHelper) GetLatestBlockNumber ¶
func (eipHelper *EIP1559TransactionHelper) GetLatestBlockNumber() (*big.Int, error)
func (*EIP1559TransactionHelper) GetPublicAddressFromPrivateKey ¶
func (eipHelper *EIP1559TransactionHelper) GetPublicAddressFromPrivateKey(privateKey *ecdsa.PrivateKey) (common.Address, error)
func (*EIP1559TransactionHelper) GetRpcUrl ¶
func (eipHelper *EIP1559TransactionHelper) GetRpcUrl() string
func (*EIP1559TransactionHelper) SendTransaction ¶
func (eipHelper *EIP1559TransactionHelper) SendTransaction( privateKey *ecdsa.PrivateKey, to *common.Address, chainID *big.Int, gasParams Gas1559Params, value *big.Int, data []byte, ) (receipt *types.Receipt, err error)
type ExternalErrorWrapper ¶
func (*ExternalErrorWrapper) AddContext ¶
func (e *ExternalErrorWrapper) AddContext(additionalInfo string)
func (*ExternalErrorWrapper) Error ¶
func (e *ExternalErrorWrapper) Error() string
Error is mark the struct as an error.
func (*ExternalErrorWrapper) Unwrap ¶
func (e *ExternalErrorWrapper) Unwrap() error
Unwrap is used to make it work with errors.Is, errors.As.
type Gas1559Params ¶
type TxHelperRegistry ¶
type TxHelperRegistry struct {
// contains filtered or unexported fields
}