Learn how to deploy smart contracts on Abstract.
the code hash is not known
.
To publish bytecode before deployment, all contract deployments on Abstract are performed by calling the
ContractDeployer system contract
using one of its
create,
create2,
createAccount, or
create2Account functions.
The bytecode of your smart contract and any other smart contracts that it can deploy (such as when using a factory)
must be included inside the factory dependencies (factoryDeps
) of the deployment transaction.
Typically, this process occurs under the hood and is performed by the compiler and client libraries.
This page will show you how to deploy smart contracts on Abstract by interacting with the
ContractDeployer system contract.
CREATE
and CREATE2
opcodes into calls to the create
and create2
functions on the ContractDeployer
system contract.
In addition, when you call either of these opcodes, the compiler automatically detects what other contracts
your contract is capable of deploying and includes them in the factoryDeps
field
of the generated artifacts.
CREATE
and CREATE2
is different from Ethereum.
Learn more.
CREATE
opcode. The compiler will automatically transform these calls
into calls to the create
function on the ContractDeployer
system contract.
New contract instance via create
New contract instance via create (using assembly)
CREATE2
opcode. The compiler will automatically transform these calls
into calls to the create2
function on the ContractDeployer
system contract.
New contract instance via create2
New contract instance via create2 (using assembly)
createAccount
or create2Account
function on the ContractDeployer
system contract.
This is required because the contract needs to be flagged as a smart contract wallet by setting
the fourth argument of the createAccount
function to the account abstraction version.
createAccount
function, the create2Account
function on the ContractDeployer
system contract must be
called manually when deploying smart contract wallets on Abstract to
flag the contract as a smart contract wallet by setting the fourth argument of the create2Account
function to the account abstraction version.
113
(to indicate an EIP-712 transaction).create
, create2
, createAccount
, or create2Account
function to
the
ContractDeployer
system contract address (0x0000000000000000000000000000000000008006
).customData.factoryDeps
field of the transaction.factoryDeps
field for you in the contract artifact (unless you are manually
calling the ContractDeployer
via createAccount
or create2Account
functions),
load the artifact of the contract and use the Deployer
class from the hardhat-zksync
plugin to deploy the contract.
Bootloader processes transaction
create
or create2
function on the ContractDeployer
system contract.factory_deps
field of the transaction, include the bytecode of the smart contract being deployed
as well as the bytecodes of any other contracts that this contract can deploy (such as if it is a factory contract).See the create function signature
Marking contract as known and publishing compressed bytecode
KnownCodesStorage
then calls the
Compressor, which subsequently calls the
L1Messenger
system contract to publish the hash of the compressed contract bytecode to
Ethereum (assuming this contract code has not been deployed before).Smart contract account execution
validateTransaction
and executeTransaction
functions; which
will determine whether to deploy the contract and how to execute the deployment transaction respectively.Learn more about these functions on the smart contract wallets section, or
view an example implementation in the DefaultAccount.