utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EthAddress              = common.HexToAddress("0x0000000000000000000000000000000000000000")
	BootloaderFormalAddress = common.HexToAddress("0x0000000000000000000000000000000000008001")
	ContractDeployerAddress = common.HexToAddress("0x0000000000000000000000000000000000008006")
	MessengerAddress        = common.HexToAddress("0x0000000000000000000000000000000000008008")
	L2EthTokenAddress       = common.HexToAddress("0x000000000000000000000000000000000000800a")

	L1ToL2AliasOffset = common.HexToAddress("0x1111000000000000000000000000000000001111")
	AddressModulo     = new(big.Int).Exp(big.NewInt(2), big.NewInt(160), nil)
)
View Source
var (
	// RequiredL1ToL2GasPerPubdataLimit It is possible to provide practically any gasPerPubdataByte for L1->L2 transactions,
	// since the cost per gas will be adjusted respectively. Use 800 as a relatively optimal value for now.
	RequiredL1ToL2GasPerPubdataLimit = big.NewInt(800)

	L1RecommendedMinErc20DepositGasLimit = big.NewInt(400_000)
	L1RecommendedMinEthDepositGasLimit   = big.NewInt(200_000)

	// MaxPriorityFeePerGas is fixed because L2 node does not support eth_maxPriorityFeePerGas method
	MaxPriorityFeePerGas = big.NewInt(1_000_000_000)

	L1FeeEstimationCoefNumerator   = big.NewInt(12)
	L1FeeEstimationCoefDenominator = big.NewInt(10)
)

Functions

func ApplyL1ToL2Alias

func ApplyL1ToL2Alias(address common.Address) common.Address

func CheckBaseCost

func CheckBaseCost(baseCost, value *big.Int) error

func ComputeL2Create2Address

func ComputeL2Create2Address(sender common.Address, bytecode, constructor, salt []byte) (common.Address, error)

func ComputeL2CreateAddress

func ComputeL2CreateAddress(sender common.Address, nonce *big.Int) (common.Address, error)

func Create2ContractTransaction

func Create2ContractTransaction(from common.Address, gasPrice, gasLimit *big.Int,
	bytecode, calldata hexutil.Bytes, deps []hexutil.Bytes,
	customSignature hexutil.Bytes, paymasterParams *types.PaymasterParams) *types.Transaction

func CreateETH

func CreateETH() *types.Token

func CreateFunctionCallTransaction

func CreateFunctionCallTransaction(from, to common.Address, gasPrice, gasLimit, value *big.Int, data hexutil.Bytes,
	customSignature hexutil.Bytes, paymasterParams *types.PaymasterParams) *types.Transaction

func EncodeCreate

func EncodeCreate(bytecode, calldata []byte) ([]byte, error)

func EncodeCreate2

func EncodeCreate2(bytecode, calldata, salt []byte) ([]byte, error)

func EncodeCreate2Account

func EncodeCreate2Account(bytecode, calldata, salt []byte, version types.AccountAbstractionVersion) ([]byte, error)

func EncodeCreateAccount

func EncodeCreateAccount(bytecode, calldata []byte, version types.AccountAbstractionVersion) ([]byte, error)

func GetApprovalBasedPaymasterInput

func GetApprovalBasedPaymasterInput(paymasterInput types.ApprovalBasedPaymasterInput) ([]byte, error)

func GetERC20BridgeCalldata

func GetERC20BridgeCalldata(l1TokenAddress, l1Sender, l2Receiver common.Address, amount *big.Int, bridgeData []byte) ([]byte, error)

GetERC20BridgeCalldata returns the calldata that will be sent by an L1 ERC20 bridge to its L2 counterpart during bridging of a token.

func GetERC20DefaultBridgeData

func GetERC20DefaultBridgeData(l1TokenAddress common.Address, backend bind.ContractBackend) ([]byte, error)

func GetGeneralPaymasterInput

func GetGeneralPaymasterInput(paymasterInput types.GeneralPaymasterInput) ([]byte, error)

func GetPaymasterParams

func GetPaymasterParams(paymasterAddress common.Address, paymasterInput types.PaymasterInput) (*types.PaymasterParams, error)

func HashBytecode

func HashBytecode(bytecode []byte) ([]byte, error)

func NewBig

func NewBig(n int64) *hexutil.Big

func NewBigZero

func NewBigZero() *hexutil.Big

func ReadStandardJson

func ReadStandardJson(path string) (*types.StandardConfiguration, abi.ABI, []byte, error)

ReadStandardJson reads standard-json file generated as output from zksolc. Returns standard json configuration and extracted contracts abi and bytecode from config file.

func ScaleGasLimit

func ScaleGasLimit(gasLimit *big.Int) *big.Int

func ToFilterArg

func ToFilterArg(q types.FilterQuery) (interface{}, error)

func UndoL1ToL2Alias

func UndoL1ToL2Alias(address common.Address) common.Address

Types

This section is empty.

Jump to

Keyboard shortcuts

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