contracts:deploy
Deploy a contract from raw creation bytecode. Binds the predicted address to
Supports runtime fields inside smart blocks. Use explicit @helper! expressions or captured outputs; other fields are evaluated at build time.
Syntax
Section titled “Syntax”contracts:deploy <variable> [bytecode]Arguments
Section titled “Arguments”| Name | Type | Evaluation | Description |
|---|---|---|---|
variable | variable | Build time | Variable to bind the deployed contract address to |
[bytecode] | bytes | Runtime in smart blocks | Creation bytecode (runtime values require --create3). Constructor args are appended automatically when --constructor is set. Omit when using --mirror-chain / --mirror-address to mirror an existing deployment. |
Options
Section titled “Options”| Name | Type | Evaluation | Description |
|---|---|---|---|
--mirror-chain | chain | Build time | Chain (id or viem name like optimism) to fetch the creation bytecode from (Etherscan V2). Defaults to the current chain when only --mirror-address is set. Requires --mirror-address. |
--mirror-address | address | Build time | Address of an existing deployment to mirror. The original creation bytecode (with constructor args already appended) is fetched from Etherscan and used as the init code for this deployment. |
--constructor | string | Build time | Constructor signature like constructor(uint256,address). Requires --constructor-args. Mutually exclusive with --mirror-address. |
--constructor-args | array | Runtime in smart blocks | Constructor arguments as an array literal, e.g. [100e18 @me true]. Requires --constructor; runtime inputs require --create3. |
--create2 | bytes32 | Build time | Salt for CREATE2 deployment. Defaults to the Arachnid deterministic deployer; override factory with --via. |
--create3 | bytes32 | Build time | Salt for CREATE3 deployment. Defaults to the CreateX factory; override with --via. |
--via | address | Build time | Override the default factory address used by --create2 / --create3. |
--from | address | Build time | Deprecated: run the command inside switch --as <address> ( … ). Sender address. Defaults to the acting account. For plain CREATE this is also the prediction deployer. |
--value | number | Runtime in smart blocks | ETH to send with the deployment (in wei) |
--gas | number | Build time | Gas limit |
--max-fee-per-gas | number | Build time | Max fee per gas (EIP-1559) |
--max-priority-fee-per-gas | number | Build time | Max priority fee per gas (EIP-1559) |
--nonce | number | Build time | Transaction nonce override. For plain CREATE deployments it also pins the predicted contract address. |
Examples
Section titled “Examples”load contracts
# Plain CREATE deployment from raw bytecodecontracts:deploy $addr 0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe
# Deploy with constructor argumentscontracts:deploy $token 0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe --constructor "constructor(string,string,uint8)" --constructor-args ["My Token" "MTK" 18]
# CREATE2 via the Arachnid deterministic deployer (default)contracts:deploy $vault 0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe --create2 0x0000000000000000000000000000000000000000000000000000000000000001
# CREATE2 via a custom factory (must accept salt || initCode calldata)contracts:deploy $vault2 0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe --create2 0x0000000000000000000000000000000000000000000000000000000000000001 --via 0x4e59b44847b379578588920ca78fbf26c0b4956c
# CREATE3 via the CreateX factory (default)contracts:deploy $proxy 0x6080604052348015600f57600080fd5b50603f80601d6000396000f3fe --create3 0x0000000000000000000000000000000000000000000000000000000000000002 --constructor "constructor(address)" --constructor-args [@me]
# Mirror an existing deployment from another chain — fetches the# original creation bytecode (with constructor args already baked in)# from Etherscan and replays it byte-for-byte on the current chain.contracts:deploy $clone --mirror-chain 1 --mirror-address 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
# Same flow, deterministically pinned to a CREATE2 address so the# clone lands at the same address on every chain that runs this script.contracts:deploy $clone2 --mirror-chain 1 --mirror-address 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 --create2 0x0000000000000000000000000000000000000000000000000000000000000003
# Use the bound address in subsequent callsexec $token "transfer(address,uint256)" @me 1e18- CREATE (default): the EVM derives the address from
(sender, nonce). The sender is the acting account: the connected one, or the account of an enclosingswitch --as <address> ( … )orsim:fork --as <address>. The command uses an internal per-script nonce counter so multiple deploys in the same script chain correctly. - CREATE2 (
--create2 <salt>): tx is sent to a CREATE2 factory with calldatasalt(32) || initCode. The default factory is the Arachnid deterministic deployer at0x4e59b44847b379578588920ca78fbf26c0b4956c. The predicted address depends on(factory, salt, initCode)only, so the sender does not affect it. - CREATE3 (
--create3 <salt>): tx callsdeployCreate3(bytes32,bytes)on a CreateX-compatible factory (default0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed). The deployed address depends only on(factory, salt), not on the bytecode. Permissioned salts (first 20 bytes equal the sender, or zero-prefixed with0x01in byte 20) are rejected so client-side prediction stays deterministic. - Mirror (
--mirror-address <addr> [--mirror-chain <id>]): fetches the original creation bytecode of an existing deployment from Etherscan V2'sgetcontractcreationendpoint and uses it as the init code for this deployment. The fetched bytecode already includes the original ABI-encoded constructor arguments, so--constructor/--constructor-argsare not allowed in this mode. Combine with--create2/--create3to pin the cloned contract to a deterministic address. Needs access to Etherscan: the terminal has it through the EVMcrispr API, the CLI readsVITE_ETHERSCAN_API_KEY.
Caveats
Section titled “Caveats”--fromis deprecated: to deploy from another account, run the command insideswitch --as <address> ( … ). The address prediction follows.- A command and all of its options must be written on a single line — EVML
has no
\line continuation. - A
deployaction is a CREATE transaction (notofield) when neither--create2nor--create3is set. Such actions cannot be executed inside abatch (...)block via EIP-5792 wallet batching — use--create2or--create3if you need to batch deployments together with other calls.
See Also
Section titled “See Also”- @contracts:next — predict the next CREATE address for an account
- exec — call a contract function on the deployed address
- send — send a pre-encoded transaction or value transfer to an existing address