โ† Back to list
axone-protocol

cosmwasm-contract

by axone-protocol

๐Ÿ“œ Smart contracts for the Axone protocol

โญ 123๐Ÿด 19๐Ÿ“… Jan 23, 2026

SKILL.md


name: cosmwasm-contract description: Guide for developing CosmWasm smart contracts using the Abstract SDK. Use when creating new contracts, implementing handlers, or working with contract structure. license: BSD-3-Clause metadata: author: axone.xyz version: "1.0"

CosmWasm Smart Contract Development with Abstract SDK

This skill helps you develop CosmWasm smart contracts for the Axone protocol using the Abstract SDK framework.

When to use this skill

Use this skill when you need to:

  • Create a new smart contract from scratch
  • Implement contract handlers (instantiate, execute, query, migrate)
  • Define contract state and storage
  • Work with the Abstract AppContract pattern
  • Define error types for contracts

Contract Structure

Every contract follows this standard structure:

contracts/<contract-name>/
โ”œโ”€โ”€ Cargo.toml           # Dependencies and features
โ”œโ”€โ”€ Makefile.toml        # Contract-specific tasks
โ”œโ”€โ”€ README.md            # Contract documentation
โ”œโ”€โ”€ metadata.json        # Abstract module metadata
โ”œโ”€โ”€ schema/              # Generated JSON schemas
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib.rs           # Public exports and constants
โ”‚   โ”œโ”€โ”€ contract.rs      # AppContract type and entry points
โ”‚   โ”œโ”€โ”€ msg.rs           # Message types (Instantiate, Execute, Query, Migrate)
โ”‚   โ”œโ”€โ”€ state.rs         # State storage definitions
โ”‚   โ”œโ”€โ”€ error.rs         # Error types
โ”‚   โ”œโ”€โ”€ handlers/        # Handler implementations
โ”‚   โ”‚   โ”œโ”€โ”€ mod.rs
โ”‚   โ”‚   โ”œโ”€โ”€ instantiate.rs
โ”‚   โ”‚   โ”œโ”€โ”€ execute.rs
โ”‚   โ”‚   โ”œโ”€โ”€ query.rs
โ”‚   โ”‚   โ””โ”€โ”€ migrate.rs
โ”‚   โ”œโ”€โ”€ replies/         # Reply handlers (optional)
โ”‚   โ””โ”€โ”€ bin/             # Binary scripts (schema, publish, install)
โ””โ”€โ”€ tests/
    โ””โ”€โ”€ integration.rs   # Integration tests

Key Patterns

1. Module ID and Namespace (lib.rs)

pub const AXONE_NAMESPACE: &str = "axone";
pub const CONTRACT_NAME: &str = "my-contract";
pub const CONTRACT_ID: &str = const_format::concatcp!(AXONE_NAMESPACE, ":", CONTRACT_NAME);
pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");

2. AppContract Definition (contract.rs)

use abstract_app::AppContract;

pub type MyContract = AppContract<
    MyContractError,
    MyContractInstantiateMsg,
    MyContractExecuteMsg,
    MyContractQueryMsg,
    MyContractMigrateMsg,
>;

const APP: MyContract = MyContract::new(CONTRACT_ID, APP_VERSION, None)
    .with_instantiate(handlers::instantiate_handler)
    .with_execute(handlers::execute_handler)
    .with_query(handlers::query_handler)
    .with_migrate(handlers::migrate_handler)
    .with_dependencies(&[]);

#[cfg(feature = "export")]
abstract_app::export_endpoints!(APP, MyContract);

abstract_app::cw_orch_interface!(APP, MyContract, MyContractInterface);

3. Handler Functions

// handlers/execute.rs
use crate::contract::{MyContract, MyContractResult};
use crate::msg::MyContractExecuteMsg;
use abstract_app::traits::AbstractNameService;

pub fn execute_handler(
    deps: DepsMut,
    env: Env,
    info: MessageInfo,
    app: MyContract,
    msg: MyContractExecuteMsg,
) -> MyContractResult {
    match msg {
        MyContractExecuteMsg::DoSomething { param } => do_something(deps, env, info, app, param),
    }
}

4. State Management (state.rs)

use cw_storage_plus::{Item, Map};

pub const CONFIG: Item<Config> = Item::new("config");
pub const ITEMS: Map<&str, ItemData> = Map::new("items");

5. Error Types (error.rs)

use thiserror::Error;

#[derive(Debug, Error, PartialEq)]
pub enum MyContractError {
    #[error("{0}")]
    Std(#[from] StdError),

    #[error("{0}")]
    Abstract(#[from] AbstractError),

    #[error("{0}")]
    AbstractSdk(#[from] AbstractSdkError),

    #[error("{0}")]
    DappError(#[from] AppError),

    // Custom errors
    #[error("Unauthorized")]
    Unauthorized {},
}

Building and Testing

# Build the contract
cargo make build

# Build WASM
cargo make wasm

# Run tests
cargo make test-unit

# Generate schemas
cargo make schema

Best Practices

  1. Use Abstract SDK features - Leverage AbstractNameService, Bank, and other SDK modules
  2. Keep handlers focused - Each handler function should do one thing well
  3. Document all messages - Every message variant needs doc comments for schema generation
  4. Derive traits consistently - Use cw_serde, ExecuteFns, QueryFns
  5. Test error cases - Cover both success and failure paths in tests

Score

Total Score

75/100

Based on repository quality metrics

โœ“SKILL.md

SKILL.mdใƒ•ใ‚กใ‚คใƒซใŒๅซใพใ‚Œใฆใ„ใ‚‹

+20
โœ“LICENSE

ใƒฉใ‚คใ‚ปใƒณใ‚นใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+10
โ—‹่ชฌๆ˜Žๆ–‡

100ๆ–‡ๅญ—ไปฅไธŠใฎ่ชฌๆ˜ŽใŒใ‚ใ‚‹

0/10
โœ“ไบบๆฐ—

GitHub Stars 100ไปฅไธŠ

+5
โœ“ๆœ€่ฟ‘ใฎๆดปๅ‹•

1ใƒถๆœˆไปฅๅ†…ใซๆ›ดๆ–ฐ

+10
โœ“ใƒ•ใ‚ฉใƒผใ‚ฏ

10ๅ›žไปฅไธŠใƒ•ใ‚ฉใƒผใ‚ฏใ•ใ‚Œใฆใ„ใ‚‹

+5
โœ“Issue็ฎก็†

ใ‚ชใƒผใƒ—ใƒณIssueใŒ50ๆœชๆบ€

+5
โœ“่จ€่ชž

ใƒ—ใƒญใ‚ฐใƒฉใƒŸใƒณใ‚ฐ่จ€่ชžใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5
โœ“ใ‚ฟใ‚ฐ

1ใคไปฅไธŠใฎใ‚ฟใ‚ฐใŒ่จญๅฎšใ•ใ‚Œใฆใ„ใ‚‹

+5

Reviews

๐Ÿ’ฌ

Reviews coming soon