Documentation
¶
Index ¶
- Variables
- func ApplyL1ToL2Alias(address common.Address) common.Address
- func CheckBaseCost(baseCost, value *big.Int) error
- func Create2Address(sender common.Address, bytecode, constructor, salt []byte) (common.Address, error)
- func CreateAddress(sender common.Address, nonce *big.Int) (common.Address, error)
- func CreateETH() *types.Token
- func EncodeCreate(bytecode, calldata []byte) ([]byte, error)
- func EncodeCreate2(bytecode, calldata, salt []byte) ([]byte, error)
- func EncodeCreate2Account(bytecode, calldata, salt []byte, version types.AccountAbstractionVersion) ([]byte, error)
- func EncodeCreateAccount(bytecode, calldata []byte, version types.AccountAbstractionVersion) ([]byte, error)
- func Erc20BridgeCalldata(l1TokenAddress, l1Sender, l2Receiver common.Address, amount *big.Int, ...) ([]byte, error)
- func Erc20DefaultBridgeData(l1TokenAddress common.Address, backend bind.ContractBackend) ([]byte, error)
- func GetApprovalBasedPaymasterInput(paymasterInput types.ApprovalBasedPaymasterInput) ([]byte, error)
- func GetGeneralPaymasterInput(paymasterInput types.GeneralPaymasterInput) ([]byte, error)
- func GetPaymasterParams(paymasterAddress common.Address, paymasterInput types.PaymasterInput) (*types.PaymasterParams, error)
- func HashBytecode(bytecode []byte) ([]byte, error)
- func HashedL2ToL1Msg(sender common.Address, msg []byte, txNumberInBlock uint16) common.Hash
- func IsMessageSignatureCorrect(address common.Address, msg, sig []byte) (bool, error)
- func IsTypedDataSignatureCorrect(address common.Address, typedData apitypes.TypedData, sig []byte) (bool, error)
- func NewBig(n int64) *hexutil.Big
- func NewBigZero() *hexutil.Big
- func NewCallMsg(call ethereum.CallMsg) *types.CallMsg
- func ReadStandardJson(path string) (*types.StandardConfiguration, abi.ABI, []byte, error)
- func ScaleGasLimit(gasLimit *big.Int) *big.Int
- func UndoL1ToL2Alias(address common.Address) common.Address
Constants ¶
This section is empty.
Variables ¶
var ( // EthAddress The address of the L1 ETH token. EthAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") // LegacyEthAddress The address of the L1 ETH token. LegacyEthAddress = common.HexToAddress("0x0000000000000000000000000000000000000000") // EthAddressInContracts In the contracts the zero address can not be used, use one instead. EthAddressInContracts = common.HexToAddress("0x0000000000000000000000000000000000000001") // BootloaderFormalAddress The formal address for the Bootloader. BootloaderFormalAddress = common.HexToAddress("0x0000000000000000000000000000000000008001") // ContractDeployerAddress The address of the Contract deployer. ContractDeployerAddress = common.HexToAddress("0x0000000000000000000000000000000000008006") // L1MessengerAddress The address of the L1 messenger. L1MessengerAddress = common.HexToAddress("0x0000000000000000000000000000000000008008") // L2BaseTokenAddress The address of the base token. L2BaseTokenAddress = common.HexToAddress("0x000000000000000000000000000000000000800a") // NonceHolderAddress The address of the Nonce holder. NonceHolderAddress = common.HexToAddress("0x0000000000000000000000000000000000008003") // L1ToL2AliasOffset Used for applying and undoing aliases on contract addresses during bridging from L1 to L2. L1ToL2AliasOffset = common.HexToAddress("0x1111000000000000000000000000000000001111") AddressModulo = new(big.Int).Exp(big.NewInt(2), big.NewInt(160), nil) // Eip1271MagicValue indicates the signature used by EIP-1271 is valid. Eip1271MagicValue = [4]byte(common.FromHex("0x1626ba7e")) )
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) // DefaultGasPerPubdataLimit The large L2 gas per pubdata to sign. This gas is enough to ensure that // any reasonable limit will be accepted. Note, that the operator is NOT required to // use the honest value of gas per pubdata, and it can use any value up to the one signed by the user. // In the future releases, we will provide a way to estimate the current gasPerPubdata. DefaultGasPerPubdataLimit = big.NewInt(50_000) // MaxPriorityFeePerGas is fixed because L2 node does not support eth_maxPriorityFeePerGas method MaxPriorityFeePerGas = big.NewInt(1_000_000_000) // L1RecommendedMinErc20DepositGasLimit This gas limit will be used for displaying the error messages when the users do not have enough fee. L1RecommendedMinErc20DepositGasLimit = big.NewInt(400_000) // L1RecommendedMinEthDepositGasLimit This gas limit will be used for displaying the error messages when the users do not have enough fee. L1RecommendedMinEthDepositGasLimit = big.NewInt(200_000) )
Functions ¶
func ApplyL1ToL2Alias ¶
ApplyL1ToL2Alias converts the address of smart contract that submitted a transaction to the inbox on L1 to the `msg.sender` viewed on L2.
func CheckBaseCost ¶
CheckBaseCost checks if the provided base cost is greater than the provided value. If it is, return an error indicating that there are not enough funds.
func Create2Address ¶ added in v0.3.0
func Create2Address(sender common.Address, bytecode, constructor, salt []byte) (common.Address, error)
Create2Address generates a future-proof contract address using salt plus bytecode which allows determination of an address before deployment.
func CreateAddress ¶ added in v0.3.0
CreateAddress generates a contract address from deployer's account and nonce.
func EncodeCreate ¶
EncodeCreate encodes the constructor data for CREATE method used for smart contract deployment.
func EncodeCreate2 ¶
EncodeCreate2 returns the encoded constructor data for CREATE2 method used for smart contract deployment.
func EncodeCreate2Account ¶
func EncodeCreate2Account(bytecode, calldata, salt []byte, version types.AccountAbstractionVersion) ([]byte, error)
EncodeCreate2Account encodes the constructor data for CREATE2 method used for smart account deployment.
func EncodeCreateAccount ¶
func EncodeCreateAccount(bytecode, calldata []byte, version types.AccountAbstractionVersion) ([]byte, error)
EncodeCreateAccount encodes the constructor data for CREATE method used for smart account deployment.
func Erc20BridgeCalldata ¶ added in v0.3.0
func Erc20BridgeCalldata(l1TokenAddress, l1Sender, l2Receiver common.Address, amount *big.Int, bridgeData []byte) ([]byte, error)
Erc20BridgeCalldata returns the calldata that will be sent by an L1 ERC20 bridge to its L2 counterpart during bridging of a token.
func Erc20DefaultBridgeData ¶ added in v0.3.0
func Erc20DefaultBridgeData(l1TokenAddress common.Address, backend bind.ContractBackend) ([]byte, error)
Erc20DefaultBridgeData Returns the data needed for correct initialization of an L1 token counterpart on L2.
func GetApprovalBasedPaymasterInput ¶
func GetApprovalBasedPaymasterInput(paymasterInput types.ApprovalBasedPaymasterInput) ([]byte, error)
GetApprovalBasedPaymasterInput returns encoded input for an approval-based paymaster.
func GetGeneralPaymasterInput ¶
func GetGeneralPaymasterInput(paymasterInput types.GeneralPaymasterInput) ([]byte, error)
GetGeneralPaymasterInput returns encoded input for a general-based paymaster.
func GetPaymasterParams ¶
func GetPaymasterParams(paymasterAddress common.Address, paymasterInput types.PaymasterInput) (*types.PaymasterParams, error)
GetPaymasterParams returns a correctly-formed paymaster parameters for common paymaster flows.
func HashBytecode ¶
HashBytecode returns the hash of given bytecode.
func HashedL2ToL1Msg ¶ added in v0.7.0
HashedL2ToL1Msg returns a `keccak` encoded message with a given sender address and block number from the L1 messenger contract.
func IsMessageSignatureCorrect ¶ added in v0.7.0
IsMessageSignatureCorrect checks whether the message ECDSA signature is correct.
func IsTypedDataSignatureCorrect ¶ added in v0.7.0
func IsTypedDataSignatureCorrect(address common.Address, typedData apitypes.TypedData, sig []byte) (bool, error)
IsTypedDataSignatureCorrect checks whether the typed data ECDSA signature is correct.
func NewBigZero ¶
func NewCallMsg ¶ added in v0.3.0
NewCallMsg converts ethereum call message to L2 message.
func ReadStandardJson ¶
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 ¶
ScaleGasLimit scales the provided gas limit using a coefficient to ensure acceptance of L1->L2 transactions.
Types ¶
This section is empty.