Skip to main content

Project Scaffolding

The xyz init command creates a complete CosmWasm contract project with all the necessary files and configurations.

Usage

Options

Create a Project

Project Structure

File Contents

Cargo.toml

src/lib.rs

src/msg.rs

src/state.rs

src/error.rs

src/contract.rs

Templates

CW20 Template (Default)

Token contract template based on CW20 standard:
Creates a fungible token contract with:
  • Token minting
  • Transfers
  • Balance queries
  • Allowances

Overwrite Existing

To overwrite an existing directory:
This will delete all existing files in the directory!

Next Steps

After scaffolding:

Customizing the Contract

Add New Execute Messages

  1. Add variant to ExecuteMsg in src/msg.rs:
  1. Handle in src/contract.rs:

Add New Queries

  1. Add variant to QueryMsg in src/msg.rs:
  1. Handle in src/contract.rs:

Add State

  1. Define in src/state.rs:
  1. Use in contract:

Troubleshooting

Use --force to overwrite:
Check write permissions for the current directory.