Skip to main content

Deploying Contracts

The xyz program deploy command uploads your contract to the chain and creates an instance in a single step.

Usage

Basic Deployment

Options

Examples

With Instantiate Message

From Message File

With Initial Funds

Immutable Contract (No Admin)

Immutable contracts cannot be upgraded or migrated. Use this for production contracts that should never change.

Custom Admin

Dry Run

Simulate deployment without broadcasting:
Output:

Deployment Flow

xyz program deploy combines two operations:

Step 1: Store Code

Uploads the Wasm bytecode to the chain:
  • Creates a unique Code ID
  • Bytecode stored in chain state
  • Same code can be instantiated multiple times

Step 2: Instantiate

Creates a contract instance:
  • New contract address generated
  • Initial state set via InstantiateMsg
  • Admin assigned (for migrations)

Separate Upload and Instantiate

For advanced use cases, separate the steps:

Multiple Instances

Create multiple instances of the same code:

Error Handling

Common errors and solutions:

User-Friendly Errors

The CLI translates chain errors:

Verify Deployment

After deployment:

Troubleshooting

The Wasm file may be invalid:
Check balance:
For localnet, use test accounts with pre-funded balances.
Check your JSON:
Ensure it matches InstantiateMsg in your contract.
Node may be slow: