IContractDeployer
Author: Matter Labs
Interface of the contract deployer contract -- a system contract responsible for deploying other contracts.
Note: security-contact: security@matterlabs.dev
Functions
allowedBytecodeTypesToDeploy
Returns what types of bytecode are allowed to be deployed on this chain.
function allowedBytecodeTypesToDeploy()
external
view
returns (AllowedBytecodeTypes mode);
Returns
| Name | Type | Description |
|---|---|---|
mode | AllowedBytecodeTypes | The allowed bytecode types mode. |
getNewAddressCreate2
Calculates the address of a deployed contract via create2
function getNewAddressCreate2(
address _sender,
bytes32 _bytecodeHash,
bytes32 _salt,
bytes calldata _input
) external view returns (address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The account that deploys the contract. |
_bytecodeHash | bytes32 | The correctly formatted hash of the bytecode. |
_salt | bytes32 | The create2 salt. |
_input | bytes | The constructor data. |
Returns
| Name | Type | Description |
|---|---|---|
newAddress | address | The derived address of the account. |
getNewAddressCreate
Calculates the address of a deployed contract via create
function getNewAddressCreate(address _sender, uint256 _senderNonce)
external
pure
returns (address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The account that deploys the contract. |
_senderNonce | uint256 | The deploy nonce of the sender's account. |
Returns
| Name | Type | Description |
|---|---|---|
newAddress | address | The derived address of the contract. |
create2
Deploys a contract with similar address derivation rules to the EVM's CREATE2 opcode.
function create2(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input)
external
payable
returns (address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_salt | bytes32 | The CREATE2 salt |
_bytecodeHash | bytes32 | The correctly formatted hash of the bytecode. |
_input | bytes | The constructor calldata |
Returns
| Name | Type | Description |
|---|---|---|
newAddress | address | The derived address of the contract. |
create2Account
Deploys a contract account with similar address derivation rules to the EVM's CREATE2 opcode.
this method may be callable only in system mode,
that is checked in the createAccount by onlySystemCall modifier.
function create2Account(
bytes32 _salt,
bytes32 _bytecodeHash,
bytes calldata _input,
AccountAbstractionVersion _aaVersion
) external payable returns (address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_salt | bytes32 | The CREATE2 salt |
_bytecodeHash | bytes32 | The correctly formatted hash of the bytecode. |
_input | bytes | The constructor calldata. |
_aaVersion | AccountAbstractionVersion | The account abstraction version to use. |
Returns
| Name | Type | Description |
|---|---|---|
newAddress | address | The derived address of the contract. |
create
Deploys a contract with similar address derivation rules to the EVM's CREATE opcode.
Although this method accepts salt as one of its parameters.
It is not used anywhere and is needed simply for the consistency for the compiler
Note: this method may be callable only in system mode,
that is checked in the createAccount by onlySystemCall modifier.
function create(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input)
external
payable
returns (address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_salt | bytes32 | A 32-byte salt. |
_bytecodeHash | bytes32 | The correctly formatted hash of the bytecode. |
_input | bytes | The constructor calldata |
Returns
| Name | Type | Description |
|---|---|---|
newAddress | address | The derived address of the contract. |
createAccount
Deploys a contract account with similar address derivation rules to the EVM's CREATE opcode.
This method also accepts salt as one of its parameters. It is not used anywhere and it needed simply for the consistency for the compiler
function createAccount(
bytes32,
bytes32 _bytecodeHash,
bytes calldata _input,
AccountAbstractionVersion _aaVersion
) external payable returns (address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | |
_bytecodeHash | bytes32 | The correctly formatted hash of the bytecode. |
_input | bytes | The constructor calldata. |
_aaVersion | AccountAbstractionVersion | The account abstraction version to use. |
Returns
| Name | Type | Description |
|---|---|---|
newAddress | address | The derived address of the contract. |
getAccountInfo
Returns information about a certain account.
function getAccountInfo(address _address)
external
view
returns (AccountInfo memory info);
Parameters
| Name | Type | Description |
|---|---|---|
_address | address | The address of the account. |
Returns
| Name | Type | Description |
|---|---|---|
info | AccountInfo | The information about the account (AA version and nonce ordering). |
extendedAccountVersion
Returns the account abstraction version if _address is a deployed contract.
Returns the latest supported account abstraction version if _address is an EOA.
function extendedAccountVersion(address _address)
external
view
returns (AccountAbstractionVersion);
Parameters
| Name | Type | Description |
|---|---|---|
_address | address | The address of the account. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | AccountAbstractionVersion | The account abstraction version of the account. In particular, Version1 for EOAs, None for non-account contracts. . |
updateAccountVersion
Update the used version of the account.
Note that it allows changes from account to non-account and vice versa.
function updateAccountVersion(AccountAbstractionVersion _version) external;
Parameters
| Name | Type | Description |
|---|---|---|
_version | AccountAbstractionVersion | The new version of the AA protocol to use. |
updateNonceOrdering
Updates the nonce ordering of the account. Since only KeyedSequential ordering
is supported, currently this method always reverts.
function updateNonceOrdering(AccountNonceOrdering) external;
forceDeployOnAddresses
This method is to be used only during an upgrade to set bytecodes on specific addresses.
We do not require onlySystemCall here, since the method is accessible only
by FORCE_DEPLOYER.
function forceDeployOnAddresses(ForceDeployment[] calldata _deployments)
external
payable;
Parameters
| Name | Type | Description |
|---|---|---|
_deployments | ForceDeployment[] | The list of forced deployments to be done. |
createEVM
Deploys an EVM contract using address derivation of EVM's CREATE opcode.
Note: this method may be callable only in system mode.
function createEVM(bytes calldata _initCode)
external
payable
returns (uint256 evmGasUsed, address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_initCode | bytes | The init code for the contract. |
Returns
| Name | Type | Description |
|---|---|---|
evmGasUsed | uint256 | The amount of EVM gas used. |
newAddress | address | The address of created contract. |
create2EVM
Deploys an EVM contract using address derivation of EVM's CREATE2 opcode.
Note: this method may be callable only in system mode.
function create2EVM(bytes32 _salt, bytes calldata _initCode)
external
payable
returns (uint256 evmGasUsed, address newAddress);
Parameters
| Name | Type | Description |
|---|---|---|
_salt | bytes32 | The CREATE2 salt. |
_initCode | bytes | The init code for the contract. |
Returns
| Name | Type | Description |
|---|---|---|
evmGasUsed | uint256 | The amount of EVM gas used. |
newAddress | address | The address of created contract. |
setAllowedBytecodeTypesToDeploy
Changes what types of bytecodes are allowed to be deployed on the chain.
function setAllowedBytecodeTypesToDeploy(
AllowedBytecodeTypes newAllowedBytecodeTypes
) external;
Parameters
| Name | Type | Description |
|---|---|---|
newAllowedBytecodeTypes | AllowedBytecodeTypes | The new allowed bytecode types mode. |
Events
ContractDeployed
Emitted when a contract is deployed.
event ContractDeployed(
address indexed deployerAddress,
bytes32 indexed bytecodeHash,
address indexed contractAddress
);
Parameters
| Name | Type | Description |
|---|---|---|
deployerAddress | address | The address of the deployer. |
bytecodeHash | bytes32 | The formatted hash of the bytecode that was deployed. |
contractAddress | address | The address of the newly deployed contract. |
AccountNonceOrderingUpdated
Emitted when account's nonce ordering is updated.
Since currently only KeyedSequential ordering is supported and updating is not possible,
the event is not emitted and is reserved for future use when updating becomes possible.
event AccountNonceOrderingUpdated(
address indexed accountAddress, AccountNonceOrdering nonceOrdering
);
Parameters
| Name | Type | Description |
|---|---|---|
accountAddress | address | The address of the account. |
nonceOrdering | AccountNonceOrdering | The new nonce ordering of the account. |
AccountVersionUpdated
Emitted when account's AA version is updated.
event AccountVersionUpdated(
address indexed accountAddress, AccountAbstractionVersion aaVersion
);
Parameters
| Name | Type | Description |
|---|---|---|
accountAddress | address | The address of the contract. |
aaVersion | AccountAbstractionVersion | The new AA version of the contract. |
AllowedBytecodeTypesModeUpdated
Emitted when the allowed bytecode types mode is updated (e.g. from EraVm to EraVmAndEVM).
event AllowedBytecodeTypesModeUpdated(AllowedBytecodeTypes mode);
Parameters
| Name | Type | Description |
|---|---|---|
mode | AllowedBytecodeTypes | The new allowed bytecode types mode. |
Structs
AccountInfo
Information about an account contract.
For EOA and simple contracts (i.e. not accounts) this has default value,
which corresponds to AccountAbstractionVersion.None.and AccountNonceOrdering.KeyedSequential.
struct AccountInfo {
AccountAbstractionVersion supportedAAVersion;
AccountNonceOrdering nonceOrdering;
}
Enums
AccountAbstractionVersion
Defines the version of the account abstraction protocol that a contract claims to follow.
Nonemeans that the account is just a contract and it should never be interacted with as a custom accountVersion1means that the account follows the first version of the account abstraction protocol
enum AccountAbstractionVersion {
None,
Version1
}
AccountNonceOrdering
Defines the nonce ordering used by the account
KeyedSequentialmeans that it is expected that the nonces are monotonic and increment by 1 at a time for each key (nonces are split 192:64 bits into nonceKey:nonceValue parts, as proposed by EIP-4337).Arbitraryordering is deprecated.
This ordering is more of a suggestion to the operator on how the AA expects its transactions to be processed and is not considered as a system invariant.
enum AccountNonceOrdering {
KeyedSequential,
__DEPRECATED_Arbitrary
}
AllowedBytecodeTypes
Defines what types of bytecode are allowed to be deployed on this chain
EraVmmeans that only native contracts can be deployedEraVmAndEVMmeans that native contracts and EVM contracts can be deployed
enum AllowedBytecodeTypes {
EraVm,
EraVmAndEVM
}