util

package
v0.1.92 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Silent = 0
	Panic  = 100
	Fatal  = 200
	Error  = 300
	Warn   = 400
	Info   = 500
	Debug  = 600
	Trace  = 700
)

Verbosity levels. https://pkg.go.dev/github.com/rs/zerolog#readme-leveled-logging

View Source
const DefaultMulticall3Addr = "0xcA11bde05977b3631167028862bE2a173976CA11"

Variables

This section is empty.

Functions

func BlockUntilSuccessful

func BlockUntilSuccessful(ctx context.Context, c *ethclient.Client, retryable func() error) error

func Ecrecover

func Ecrecover(block *types.Block) ([]byte, error)

func EcrecoverTx added in v0.1.73

func EcrecoverTx(tx *types.Transaction) ([]byte, error)

func GetAddress added in v0.1.88

func GetAddress(ctx context.Context, privateKey *ecdsa.PrivateKey) common.Address

func GetAddressAndPrivateKeyHex added in v0.1.88

func GetAddressAndPrivateKeyHex(ctx context.Context, privateKey *ecdsa.PrivateKey) (string, string)

Returns the address and private key of the given private key

func GetBlockRange

func GetBlockRange(ctx context.Context, from, to uint64, c *ethrpc.Client, onlyTxHashes bool) ([]*json.RawMessage, error)

func GetBlockRangeInPages

func GetBlockRangeInPages(ctx context.Context, from, to, pageSize uint64, c *ethrpc.Client, onlyTxHashes bool) ([]*json.RawMessage, error)

func GetForkID added in v0.1.63

func GetForkID(rpc *ethrpc.Client) (uint64, error)

func GetHexString added in v0.1.65

func GetHexString(data any) string

func GetPrivateKeyHex added in v0.1.88

func GetPrivateKeyHex(privateKey *ecdsa.PrivateKey) string

func GetReceipts

func GetReceipts(ctx context.Context, rawBlocks []*json.RawMessage, c *ethrpc.Client, batchSize uint64) ([]*json.RawMessage, error)

func GetRollupAddress added in v0.1.63

func GetRollupAddress(rpc *ethrpc.Client) (string, error)

func GetRollupManagerAddress added in v0.1.63

func GetRollupManagerAddress(rpc *ethrpc.Client) (string, error)

func GetTxPoolStatus

func GetTxPoolStatus(rpc *ethrpc.Client) (uint64, uint64, error)

func GetZkEVMBatches

func GetZkEVMBatches(rpc *ethrpc.Client) (uint64, uint64, uint64, error)

func HexToBigInt

func HexToBigInt(hexString string) (*big.Int, error)

HexToBigInt converts a hexadecimal string to a big integer.

func IsMulticall3Supported added in v0.1.90

func IsMulticall3Supported(ctx context.Context, c *ethclient.Client, tryDeployIfNotExist bool, tops *bind.TransactOpts, customAddr *common.Address) (*common.Address, bool)

func Multicall3Deploy added in v0.1.90

func Multicall3Exists added in v0.1.90

func Multicall3Exists(ctx context.Context, c *ethclient.Client, customAddr *common.Address) (common.Address, bool, error)

func Multicall3FundAccountsWithERC20Token added in v0.1.92

func Multicall3FundAccountsWithERC20Token(ctx context.Context, c *ethclient.Client, tops *bind.TransactOpts, accounts []common.Address, tokenAddress common.Address, amount *big.Int, customAddr *common.Address) (approveTx, transfersTx *types.Transaction, err error)

func Multicall3FundAccountsWithNativeToken added in v0.1.90

func Multicall3FundAccountsWithNativeToken(c *ethclient.Client, tops *bind.TransactOpts, accounts []common.Address, amount *big.Int, customAddr *common.Address) (*types.Transaction, error)

func Multicall3MaxAccountsToFundPerTx added in v0.1.90

func Multicall3MaxAccountsToFundPerTx(ctx context.Context, c *ethclient.Client) (uint64, error)

func Multicall3New added in v0.1.90

func Multicall3New(c *ethclient.Client, customAddr *common.Address) (common.Address, *multicall3.Multicall3, error)

func ParseVerbosity added in v0.1.90

func ParseVerbosity(v string) (int, error)

ParseVerbosity parses a verbosity string (e.g., "info", "debug") or integer and returns the corresponding verbosity level.

func ReadPrivateKeysFromFile added in v0.1.88

func ReadPrivateKeysFromFile(sendingAddressesFile string) ([]*ecdsa.PrivateKey, error)

func SendTx

func SendTx(ctx context.Context, c *ethclient.Client, privateKey *ecdsa.PrivateKey, to *common.Address, amount *big.Int, data []byte, gasLimit uint64) error

SendTx is a simple wrapper to send a transaction from one Ethereum address to another.

func SetLogLevel

func SetLogLevel(verbosity int)

SetLogLevel sets the log level based on the flags. https://logging.apache.org/log4j/2.x/manual/customloglevels.html

func SetLogMode

func SetLogMode(mode LogMode) error

SetLogMode updates the log format.

func ValidateUrl

func ValidateUrl(input string) error

ValidateUrl checks if a string URL can be parsed and if it has a valid scheme.

func WaitReceipt added in v0.1.92

func WaitReceipt(ctx context.Context, client *ethclient.Client, txHash common.Hash) (*types.Receipt, error)

WaitReceipt waits for a transaction receipt with default parameters.

func WaitReceiptWithRetries added in v0.1.92

func WaitReceiptWithRetries(ctx context.Context, client *ethclient.Client, txHash common.Hash, maxRetries uint, initialDelayMs uint) (*types.Receipt, error)

WaitReceiptWithRetries waits for a transaction receipt with retries and exponential backoff.

func WaitReceiptWithTimeout added in v0.1.92

func WaitReceiptWithTimeout(ctx context.Context, client *ethclient.Client, txHash common.Hash, timeout time.Duration) (*types.Receipt, error)

WaitReceiptWithTimeout waits for a transaction receipt with a specified timeout.

func WrapDeployedCode added in v0.1.65

func WrapDeployedCode(deployedBytecode string, storageBytecode string) string

Types

type BlockUntilSuccessfulFn

type BlockUntilSuccessfulFn func(ctx context.Context, c *ethclient.Client, f func() error) error

BlockUntilSuccessfulFn is designed to wait until a specified number of Ethereum blocks have been mined, periodically checking for the completion of a given function within each block interval.

type LogMode

type LogMode string

LogMode represents the logger mode.

const (
	Console LogMode = "console"
	JSON    LogMode = "json"
)

Jump to

Keyboard shortcuts

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