IContractDeployer

Git Source

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

NameTypeDescription
modeAllowedBytecodeTypesThe 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

NameTypeDescription
_senderaddressThe account that deploys the contract.
_bytecodeHashbytes32The correctly formatted hash of the bytecode.
_saltbytes32The create2 salt.
_inputbytesThe constructor data.

Returns

NameTypeDescription
newAddressaddressThe 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

NameTypeDescription
_senderaddressThe account that deploys the contract.
_senderNonceuint256The deploy nonce of the sender's account.

Returns

NameTypeDescription
newAddressaddressThe 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

NameTypeDescription
_saltbytes32The CREATE2 salt
_bytecodeHashbytes32The correctly formatted hash of the bytecode.
_inputbytesThe constructor calldata

Returns

NameTypeDescription
newAddressaddressThe 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

NameTypeDescription
_saltbytes32The CREATE2 salt
_bytecodeHashbytes32The correctly formatted hash of the bytecode.
_inputbytesThe constructor calldata.
_aaVersionAccountAbstractionVersionThe account abstraction version to use.

Returns

NameTypeDescription
newAddressaddressThe 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

NameTypeDescription
_saltbytes32A 32-byte salt.
_bytecodeHashbytes32The correctly formatted hash of the bytecode.
_inputbytesThe constructor calldata

Returns

NameTypeDescription
newAddressaddressThe 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

NameTypeDescription
<none>bytes32
_bytecodeHashbytes32The correctly formatted hash of the bytecode.
_inputbytesThe constructor calldata.
_aaVersionAccountAbstractionVersionThe account abstraction version to use.

Returns

NameTypeDescription
newAddressaddressThe derived address of the contract.

getAccountInfo

Returns information about a certain account.

function getAccountInfo(address _address)
  external
  view
  returns (AccountInfo memory info);

Parameters

NameTypeDescription
_addressaddressThe address of the account.

Returns

NameTypeDescription
infoAccountInfoThe 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

NameTypeDescription
_addressaddressThe address of the account.

Returns

NameTypeDescription
<none>AccountAbstractionVersionThe 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

NameTypeDescription
_versionAccountAbstractionVersionThe 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

NameTypeDescription
_deploymentsForceDeployment[]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

NameTypeDescription
_initCodebytesThe init code for the contract.

Returns

NameTypeDescription
evmGasUseduint256The amount of EVM gas used.
newAddressaddressThe 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

NameTypeDescription
_saltbytes32The CREATE2 salt.
_initCodebytesThe init code for the contract.

Returns

NameTypeDescription
evmGasUseduint256The amount of EVM gas used.
newAddressaddressThe address of created contract.

setAllowedBytecodeTypesToDeploy

Changes what types of bytecodes are allowed to be deployed on the chain.

function setAllowedBytecodeTypesToDeploy(
  AllowedBytecodeTypes newAllowedBytecodeTypes
) external;

Parameters

NameTypeDescription
newAllowedBytecodeTypesAllowedBytecodeTypesThe 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

NameTypeDescription
deployerAddressaddressThe address of the deployer.
bytecodeHashbytes32The formatted hash of the bytecode that was deployed.
contractAddressaddressThe 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

NameTypeDescription
accountAddressaddressThe address of the account.
nonceOrderingAccountNonceOrderingThe new nonce ordering of the account.

AccountVersionUpdated

Emitted when account's AA version is updated.

event AccountVersionUpdated(
  address indexed accountAddress, AccountAbstractionVersion aaVersion
);

Parameters

NameTypeDescription
accountAddressaddressThe address of the contract.
aaVersionAccountAbstractionVersionThe 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

NameTypeDescription
modeAllowedBytecodeTypesThe 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.

  • None means that the account is just a contract and it should never be interacted with as a custom account
  • Version1 means 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

  • KeyedSequential means 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).
  • Arbitrary ordering 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

  • EraVm means that only native contracts can be deployed
  • EraVmAndEVM means that native contracts and EVM contracts can be deployed
enum AllowedBytecodeTypes {
  EraVm,
  EraVmAndEVM
}