Skip to main content

Most Used Commands

Deploy from a Solidity file
hcli contract create \
  --name my-contract \
  --file ./MyContract.sol \
  --admin-key alice
Import an existing on-chain contract into local state
hcli contract import --contract 0.0.123456 --name my-alias
List saved contracts
hcli contract list
Delete on Hedera (beneficiary required) or drop local state only
hcli contract delete --contract my-alias --transfer-id 0.0.7890
hcli contract delete --contract 0.0.123456 --state-only

Create: --file vs --default

You must supply --file (path to a .sol file) or --default (erc20 or erc721 built-in template). They are mutually exclusive.

Full Command Reference

Compile a Solidity source (or use a built-in template), deploy the contract to the current network, and run verification where the CLI supports it.
-n, --name
string
required
Smart contract name or alias stored in CLI state.
-f, --file
string
Path to a Solidity file (absolute or relative). Use with --base-path when imports need a root directory.
-d, --default
string(erc20|erc721)
Use a built-in template instead of --file. Mutually exclusive with --file.
-b, --base-path
string
Base directory for resolving the Solidity file. Defaults to the current directory when using --file (see CLI README for --default behavior).
-g, --gas
number
default:"2000000"
Gas limit for contract creation.
-a, --admin-key
string (repeatable)
Admin key credential(s) for the new contract. Pass multiple times for KeyList / ThresholdKey style setups. See hcli contract create --help for accepted formats.
-A, --admin-key-threshold
int
M-of-N: how many of the --admin-key values must sign the create flow. Only applies when multiple --admin-key entries are provided.
-m, --memo
string
Contract memo.
-v, --solidity-version
string
Solidity compiler version to use for compilation.
-c, --constructor-parameter
string (repeatable)
Constructor argument values, in order. Repeat the flag once per argument.
-k, --key-manager
string(local|local_encrypted)
Key manager to use: local or local_encrypted (defaults to config setting).
-i, --initial-balance
string
Initial HBAR balance for the contract. Examples: 100 (HBAR) or 100t (tinybars).
-r, --auto-renew-period
string
Auto-renew period: seconds as an integer, or with suffix s, m, h, or d (e.g. 500, 500s, 50m, 2h, 30d).
-R, --auto-renew-account-id
string
Account ID (0.0.xxx) that pays for contract auto-renewal.
-t, --max-automatic-token-associations
int
Maximum automatic token associations (-1 for unlimited, 0 to disable).
-s, --staked-account-id
string
Account ID (0.0.xxx) to stake the contract to. Mutually exclusive with --staked-node-id.
-o, --staked-node-id
number
Node ID to stake the contract to. Mutually exclusive with --staked-account-id.
-D, --decline-staking-reward
boolean
Whether to decline staking rewards for this contract.
Examples
hcli contract create --name my-token --default erc20
hcli contract create --name app --file ./App.sol --admin-key alice --gas 3000000
List smart contracts stored in CLI state (including metadata such as network and verification flags where available).Example
hcli contract list
Import an existing contract from Hedera by 0.0.xxx ID or 0x… EVM address. The CLI reads contract info from the mirror node and stores admin key metadata in local state for later operations.
-c, --contract
string
required
Contract ID (0.0.xxx) or EVM address (0x…).
-n, --name
string
Optional local alias for the imported contract.
By default, submits a ContractDeleteTransaction on Hedera and then removes the contract from local state. With --state-only, only local state is cleared (no network transaction).
-c, --contract
string
required
Contract ID (0.0.xxx) or local alias.
-s, --state-only
Remove from local CLI state only. No network delete.
-t, --transfer-id
string
Account (ID or alias) that receives remaining HBAR after an on-chain delete. For a network delete, supply exactly one of --transfer-id or --transfer-contract-id. Do not combine with --state-only.
-r, --transfer-contract-id
string
Contract (ID or alias) that receives remaining HBAR. For a network delete, supply exactly one of --transfer-id or --transfer-contract-id (never both).
-a, --admin-key
string (repeatable)
Optional signing credential(s) for the network delete. Not allowed with --state-only. If omitted on a network delete, the CLI derives required admin keys from the mirror node and matches KMS keys (including M-of-N). Pass multiple times when several keys must sign.
-k, --key-manager
string(local|local_encrypted)
Key manager used when resolving --admin-key (defaults to config).
Examples
hcli contract delete --contract my-alias --transfer-id 0.0.5678
hcli contract delete --contract 0.0.123456 --state-only
This command uses requireConfirmation. In non-interactive environments, use the root --confirm flag (see Overview → Global Flags) so the CLI does not block on the prompt.
ERC-20 and ERC-721 helper plugins focus on calling deployed contracts. This page covers compile, deploy, import, list, and delete for Solidity sources and built-in erc20 / erc721 templates.