Skip to main content
Version: v. 1

Spark create

NAME

spark-create - Deploy a smart contract.

SYNOPSIS

spark create [options] contract

DESCRIPTION

Deploy a smart contract.

The path to the contract is in the format <path>:<contract>, e.g. src/Contract.sol:Contract.

You can specify constructor arguments with --constructor-args. Alternatively, you can specify a file containing space-separated constructor arguments with --constructor-args-path.

Dynamic linking is not supported: you should predeploy your libraries and manually specify their addresses (see --libraries).

ℹ️ Note

The --constructor-args flag must be positioned last in the command, since it takes multiple values.

OPTIONS

Build Options

--constructor-args args...
The constructor arguments.

--constructor-args-path file
The path to a file containing the constructor arguments.

--verify
Verify contract after creation. Runs spark verify-contract with the appropriate parameters.

--verifier name
The verification provider. Available options: etherscan, sourcify & blockscout. Default: etherscan. Note: make sure you add "/api?" to the end of the Blockscout homepage explorer URL.

--verifier-url url
The optional verifier url for submitting the verification request.
Environment: VERIFIER_URL

--unlocked
Send via eth_sendTransaction using the --from argument or $ETH_FROM as sender.

Transaction Options

--gas-limit gas_limit
Gas limit for the transaction.

--gas-price price
Gas price for the transaction, or max fee per gas for EIP1559 transactions.

--priority-gas-price price
Max priority fee per gas for EIP1559 transactions.

--value value
Ether to send in the transaction.

Either specified as an integer (wei), or as a string with a unit, for example:

  • 1ether
  • 10gwei
  • 0.01ether

--nonce nonce
Nonce for the transaction.

--legacy
Send a legacy transaction instead of an EIP1559 transaction.

This is automatically enabled for common networks without EIP1559.

WALLET OPTIONS - RAW:

-i
--interactive <NUM>
Open an interactive prompt to enter your private key. Takes a value for the number of keys to enter.
Defaults to 0.

--mnemonic-derivation-path <PATHS>
The wallet derivation path. Works with both --mnemonic-path and hardware wallets.

--mnemonic-indexes <INDEXES>
Use the private key from the given mnemonic index. Used with --mnemonic-paths.
Defaults to 0.

--mnemonic-passphrase <PASSPHRASE>
Use a BIP39 passphrases for the mnemonic.

--mnemonic <PATHS>
Use the mnemonic phrases or mnemonic files at the specified paths.

--private-key <RAW_PRIVATE_KEY>
Use the provided private key.

--private-keys <RAW_PRIVATE_KEYS>
Use the provided private keys.

Wallet Options - Keystore

--keystore path
Use the keystore in the given folder or file.
Environment: ETH_KEYSTORE

--account account-name
Use a keystore from the default keystores folder (~/.foxar/keystores) by its filename.
Environment: ETH_KEYSTORE_ACCOUNT

--interactive

--password password
The keystore password. Used with --keystore. Environment: ETH_PASSWORD

Wallet Options - Hardware Wallet

-t
--trezor
Use a Trezor hardware wallet.

-l
--ledger
Use a Ledger hardware wallet.

Wallet Options - Remote

-f address
--from address
Sign the transaction with the specified account on the RPC.
Environment: ETH_FROM

RPC Options

--rpc-url url
The RPC endpoint. Accepts a URL or an existing alias in the [rpc_endpoints] table, like mainnet. Environment: ETH_RPC_URL

--flashbots
Use the Flashbots RPC URL (https://rpc.flashbots.net).

Etherscan Options

--chain chain_name
The Etherscan chain.

--etherscan-api-key key
Etherscan API key, or the key of an Etherscan configuration table.
Environment: ETHERSCAN_API_KEY

Cache Options

--force
Clear the cache and artifacts folder and recompile.

Linker Options

--libraries libraries
Set pre-linked libraries.

The parameter must be in the format <remapped path to lib>:<library name>:<address>, e.g. src/Contract.sol:Library:0x....

Can also be set in your configuration file as libraries = ["<path>:<lib name>:<address>"].

Compiler Options

--optimize
Activate the Ylem optimizer.

--optimizer-runs runs
The number of optimizer runs.

--via-ir
Use the Yul intermediate representation compilation pipeline.

--revert-strings
How to treat revert and require reason strings.

--use solc_version
Specify the solc version, or a path to a local solc, to build with.

Valid values are in the format x.y.z, solc:x.y.z or path/to/solc.

--offline
Do not access the network. Missing solc versions will not be installed.

--no-auto-detect
Do not auto-detect solc.

--ignored-error-codes error_codes
Ignore solc warnings by error code. The parameter is a comma-separated list of error codes.

--extra-output selector
Extra output to include in the contract's artifact.

Example keys: abi, storageLayout, evm.assembly, ewasm, ir, ir-optimized, metadata.

For a full description, see the Ylem docs.

--extra-output-files selector
Extra output to write to separate files.

Example keys: abi, storageLayout, evm.assembly, ewasm, ir, ir-optimized, metadata.

For a full description, see the Ylem docs.

--evm-version version
The target EVM version.

Project Options

--build-info
Generate build info files.

--build-info-path path
Output path to directory that build info files will be written to.

--root path
The project's root path. By default, this is the root directory of the current git repository, or the current working directory.

-C path
--contracts path
The contracts source directory.
Environment: DAPP_SRC

--lib-paths path
The path to the library folder.

-R remappings
--remappings remappings
The project's remappings.

The parameter is a comma-separated list of remappings in the format <source>=<dest>.

--cache-path path
The path to the compiler cache.

--config-path file
Path to the config file.

--hh
--hardhat
This is a convenience flag, and is the same as passing --contracts contracts --lib-paths node-modules.

-o path
--out path
The project's artifacts directory.

--silent
Suppress all output.

Display Options

-j
--json
Print the deployment information as JSON.

Common Options

-h
--help
Prints help information.

EXAMPLES

  1. Deploy a contract with no constructor arguments:

    spark create src/Contract.sol:ContractWithNoConstructor
  2. Deploy a contract with two constructor arguments:

    spark create src/Contract.sol:MyToken --constructor-args "My Token" "MT"

SEE ALSO

spark, spark build