Smart Contracts
XYZ Chain supports CosmWasm smart contracts - Rust-based programs that run on the blockchain, similar to Solana programs.Why CosmWasm?
Rust Safety
Memory-safe language prevents common vulnerabilities
Familiar to Solana Devs
Rust-based like Solana programs
Rich Ecosystem
CW20, CW721, and many more standards
IBC Compatible
Cross-chain contracts via IBC
Contract Lifecycle
- Scaffold - Create project structure with
xyz init - Build - Compile Rust to optimized Wasm with
xyz program build - Deploy - Upload and instantiate with
xyz program deploy - Interact - Execute methods and query state
Commands
Quick Start
1. Start Local Network
2. Scaffold Project
3. Build Contract
4. Deploy
5. Interact
Project Structure
xyz init creates:
Key Files
Contract Entry Points
Every CosmWasm contract has three entry points:Message Types
InstantiateMsg
Configuration when creating the contract:ExecuteMsg
Actions that modify state:QueryMsg
Read-only requests:Gas & Fees
CosmWasm operations use more gas than standard transactions:
The CLI automatically estimates gas with a 1.3x buffer.
Development Workflow
1
Write Code
Modify
src/contract.rs with your logic2
Build
3
Test Locally
4
Iterate
Repeat until working correctly
5
Deploy to Testnet
Standards
Common contract standards available:Resources
Next Steps
Scaffolding
Create your first project
Building
Compile to optimized Wasm
Deploying
Deploy to the chain
Localnet
Local development network