Deploying Contracts
The bwick program deploy command uploads your contract to the chain and creates an instance in a single step.
Usage
bwick program deploy < wasm-fil e > --from < ke y > [options]
Basic Deployment
bwick program deploy artifacts/my_contract.wasm --from alice --label "My Contract"
⠋ Uploading contract...
⠙ Instantiating contract...
Contract Deployed Successfully!
Code ID: 1
Contract: bwick1abc123def456...
Label: My Contract
TxHash: ABC123DEF456...
Gas Used: 234567
Block: 12345
Options
Flag Description Default --fromSigning key Required --labelContract label Filename --msgInstantiate message (JSON or @file) {}--adminAdmin address Sender --no-adminNo admin (immutable) false --fundsInitial funds None --dry-runSimulate only false --gas-bufferGas multiplier 1.3
Examples
With Instantiate Message
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--label "Counter" \
--msg '{"count": 42}'
From Message File
# Create init.json
echo '{"count": 42, "owner": "bwick1..."}' > init.json
# Deploy with file
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--msg @init.json
With Initial Funds
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--label "Escrow" \
--funds 1000000ubwick
Immutable Contract (No Admin)
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--no-admin
Immutable contracts cannot be upgraded or migrated. Use this for production contracts that should never change.
Custom Admin
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--admin bwick1multisigaddress...
Dry Run
Simulate deployment without broadcasting:
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--dry-run
Output:
Dry run mode - transaction not broadcast
Store:
Estimated gas: 1,500,000
Estimated fee: 15,000 ubwick
Instantiate:
Estimated gas: 250,000
Estimated fee: 2,500 ubwick
Total:
Gas: 1,750,000
Fee: 17,500 ubwick
Contract Details:
Label: my_contract
Admin: bwick1youraddress...
Init msg: {}
Deployment Flow
bwick program deploy combines two operations:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Upload Wasm │────▶│ Get Code ID │────▶│ Instantiate │
│ (MsgStoreCode) │ │ (from events) │ │ (MsgInst...) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
│ │ │
▼ ▼ ▼
Upload TX Code ID: 1 Contract Address
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:
# 1. Store code only
bwickd tx wasm store artifacts/my_contract.wasm \
--from alice \
--gas auto \
--gas-adjustment 1.5 \
--chain-id bwick-1 \
-y
# 2. Get code ID
bwickd query wasm list-code --node https://rpc.bwick.fun
# 3. Instantiate
bwickd tx wasm instantiate 1 '{"count":42}' \
--from alice \
--label "Counter" \
--admin bwick1... \
--gas auto \
--gas-adjustment 1.5 \
--chain-id bwick-1 \
-y
Multiple Instances
Create multiple instances of the same code:
# First instance
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--label "Counter A" \
--msg '{"count": 0}'
# Second instance (reuses code if already uploaded)
bwick program deploy artifacts/my_contract.wasm \
--from alice \
--label "Counter B" \
--msg '{"count": 100}'
Error Handling
Common errors and solutions:
Error Cause Solution ”wasm validation failed” Invalid Wasm file Rebuild contract ”insufficient funds” Not enough ubwick Fund account ”duplicate label” Label already exists Use unique label ”instantiate error” Invalid init message Check message format
User-Friendly Errors
The CLI translates chain errors:
# Instead of raw error:
# "rpc error: code = InvalidArgument desc = ..."
# You see:
Error: contract validation failed - ensure the wasm file is a valid CosmWasm contract
Verify Deployment
After deployment:
# Check contract info
bwick program info bwick1contractaddress...
# Query contract state
bwick program query bwick1contractaddress... '{"get_count":{}}'
Troubleshooting
Contract validation failed
The Wasm file may be invalid: # Rebuild
bwick program build
# Check file
file artifacts/my_contract.wasm
Check balance: bwick balance --key alice
For localnet, use test accounts with pre-funded balances.
Invalid instantiate message
Check your JSON: # Validate JSON
echo '{"count": 42}' | jq .
Ensure it matches InstantiateMsg in your contract.
Node may be slow: # Check node status
curl https://rpc.bwick.fun/status | jq '.result.sync_info'