chain

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default timeout for waiting for a tx to be mined.
	DefaultTxTimeout    = 60 * time.Second
	DefaultGasLimit     = 2_500_000
	DefaultTipPerGasCap = 20_000_000_000 //20 GWei

)

Variables

View Source
var (
	DefaultTipCap = big.NewInt(DefaultTipPerGasCap)
)
View Source
var (
	EmptyAddress = common.Address{}
)

Functions

func DryRunTx

func DryRunTx(client *ethclient.Client, fromAddress common.Address, toAddress common.Address, value *big.Int, data []byte, timeout time.Duration) (uint64, error)

DryRunTx locally executes a transaction with the current state of blockchain and returns estimated Gas multiplied with 1.5 and potential errors.

func DryRunTxAbi

func DryRunTxAbi(client *ethclient.Client, timeout time.Duration, fromAddress common.Address, toAddress common.Address, value *big.Int, abi *abi.ABI, method string, arguments ...any) (uint64, error)

DryRunTxAbi locally executes a transaction to method with arguments with the current state of blockchain and returns estimated Gas multiplied with 1.5 and potential errors.

func EventIDFromMetadata

func EventIDFromMetadata(metaData *bind.MetaData, eventName string) (common.Hash, error)

func FunctionSelector

func FunctionSelector(signature string) (selector [4]byte)

func GetGasPrice

func GetGasPrice(gasConfig *config.Gas, client *ethclient.Client, timeout time.Duration) (*big.Int, error)

func ParseTopic

func ParseTopic(topic string) common.Hash

func PrivateKeyToEthAddress

func PrivateKeyToEthAddress(privateKey *ecdsa.PrivateKey) (common.Address, error)

func SendRawTx

func SendRawTx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, toAddress common.Address, data []byte, dryRun bool, gasConfig *config.Gas, timeout time.Duration) error

SendRawTx prepares and sends legacy transaction.

func SendRawType2Tx

func SendRawType2Tx(client *ethclient.Client, privateKey *ecdsa.PrivateKey, toAddress common.Address, data []byte, dryRun bool, gasConfig *config.Gas, timeout time.Duration) error

SendRawType2Tx prepares and sends EIP-1559 transaction. The value sent is 0.

Types

type Client

type Client interface {
	SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, gasConfig *config.Gas, timeout time.Duration, dryRun bool) error
}

type ClientImpl

type ClientImpl struct {
	EthClient *ethclient.Client
}

func (ClientImpl) SendRawTx

func (c ClientImpl) SendRawTx(privateKey *ecdsa.PrivateKey, to common.Address, payload []byte, gasConfig *config.Gas, timeout time.Duration, dryRun bool) error

SendRawTx sends a transaction with payload signed by privateKey to to address.

type TxVerifier

type TxVerifier struct {
	// contains filtered or unexported fields
}

func NewTxVerifier

func NewTxVerifier(eth *ethclient.Client) *TxVerifier

func (TxVerifier) WaitUntilMined

func (t TxVerifier) WaitUntilMined(from common.Address, tx *types.Transaction, timeout time.Duration) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL