Skip to main content

Quickstart

This guide will walk you through setting up your development environment, generating keys, and deploying your first smart contract.

Prerequisites

Before you begin, ensure you have:
  • Go 1.24+ - Download
  • Docker - For contract builds (optional but recommended)
  • Rust - For contract development (optional)

Step 1: Install the CLI

From Source

# Clone the repository
git clone https://github.com/xyzchainorg/xyz
cd xyz

# Install both binaries
make install        # Installs xyzd (chain daemon)
make install-cli    # Installs xyz (developer CLI)

Verify Installation

xyz --version
# xyz version 2.0.0

xyzd version
# xyzd version 2.0.0

Step 2: Generate a Keypair

Create your first keypair to interact with the chain:
xyz keys generate mykey
Generated new keypair: mykey

Address: xyz1abc123def456...
Mnemonic (save this securely):
abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about

WARNING: Write down your mnemonic phrase and store it securely.
This is the only way to recover your account.
Save your mnemonic phrase! This is the only way to recover your account. Never share it with anyone.

Step 3: Start Local Development Network

Launch a local testnet with pre-funded accounts:
xyz localnet start
Starting local XYZ Chain...

Chain ID:    xyz-1
RPC:         http://localhost:26657
REST:        http://localhost:1317
gRPC:        localhost:9090

Test Accounts:
  alice: xyz1... (1,000,000 XYZ)
  bob:   xyz1... (500,000 XYZ)

Local network started successfully!
The localnet provides two pre-funded test accounts:
AccountBalancePurpose
alice1,000,000 XYZDevelopment, deployment
bob500,000 XYZTesting transfers

Step 4: Check Your Balance

Query the balance of the test account:
xyz balance --key alice
Address: xyz1...
Balance: 1,000,000,000,000 uxyz (1,000,000 XYZ)

Step 5: Deploy Your First Contract

5a. Scaffold a New Project

xyz init my-token
cd my-token
This creates a complete CosmWasm project:
my-token/
├── Cargo.toml
├── src/
│   ├── lib.rs
│   ├── contract.rs
│   ├── msg.rs
│   ├── state.rs
│   └── error.rs
└── README.md

5b. Build the Contract

xyz program build
This uses Docker to create an optimized .wasm file:
Building contract with cosmwasm/optimizer:0.16.0...
Optimized wasm: artifacts/my_token.wasm (180KB)

5c. Deploy to Local Network

xyz program deploy artifacts/my_token.wasm \
  --from alice \
  --label "My First Token"
Contract Deployed Successfully!

Code ID:   1
Contract:  xyz1contract...
Label:     My First Token
TxHash:    ABC123...
Gas Used:  234567

Step 6: Interact with Your Contract

Query Contract State

xyz program query xyz1contract... '{"token_info":{}}'
{
  "name": "My Token",
  "symbol": "MTK",
  "decimals": 6,
  "total_supply": "1000000000000"
}

Execute Contract Method

xyz program execute xyz1contract... \
  '{"transfer":{"recipient":"xyz1bob...","amount":"1000000"}}' \
  --from alice
Transaction successful!
TxHash: DEF456...

Step 7: Clean Up

When you’re done, stop the local network:
xyz localnet stop

What’s Next?

Troubleshooting

Another process is using the RPC port. Stop any running chain instances:
xyz localnet stop
# or
pkill xyzd
Install Docker or use local Rust build:
xyz program build --local
Note: Local builds require Rust with wasm32-unknown-unknown target.
Make sure you’re using a funded test account:
xyz balance --key alice
If balance is zero, restart the localnet with --reset:
xyz localnet start --reset