with one click
cosmwasm-contract
// Axone contract structure and Abstract SDK patterns. Use when scaffolding or refactoring contracts, deciding layer boundaries, wiring AppContract entrypoints, or adding module metadata and replies.
// Axone contract structure and Abstract SDK patterns. Use when scaffolding or refactoring contracts, deciding layer boundaries, wiring AppContract entrypoints, or adding module metadata and replies.
Axone deployment workflows with cargo-make, cw-orch, and Abstract. Use when publishing modules, installing them on accounts, running local chain tasks, or inspecting deployments.
Domain-driven modeling patterns for Axone contracts. Use when introducing domain concepts, encoding invariants, or deciding boundaries between domain, handlers, services, gateways, queries, and state.
Repository quality gates for Rust and generated artifacts. Use when validating changes locally or before committing Rust, schema, or documentation updates.
Patterns for Rust testing in Axone CosmWasm contracts. Use when adding unit tests, integration tests, data-driven cases, or coverage-oriented test scenarios.
Best practices for designing CosmWasm smart contract APIs. Use when defining message types, designing execute/query interfaces, or optimizing API ergonomics.
Guide for writing Rust doc comments that produce accurate generated contract documentation. Use when editing Instantiate/Execute/Query/Response types or any public schema-facing API.
| name | cosmwasm-contract |
| description | Axone contract structure and Abstract SDK patterns. Use when scaffolding or refactoring contracts, deciding layer boundaries, wiring AppContract entrypoints, or adding module metadata and replies. |
| license | BSD-3-Clause |
| metadata | {"author":"axone.xyz","version":"1.0"} |
Use rust-contract-domain-modeling for invariant-heavy domain design, api-design for message surfaces, api-doc-comments for schema-facing documentation, rust-testing for tests, and rust-quality-gates for validation gates.
The repository has:
Makefile.toml for shared tasksMakefile.toml in each contract for local helperscontracts/Start from this minimal shape:
contracts/<contract-name>/
āāā Cargo.toml
āāā Makefile.toml
āāā README.md
āāā metadata.json
āāā src/
ā āāā lib.rs
ā āāā contract.rs
ā āāā msg.rs
ā āāā state.rs
ā āāā error.rs
ā āāā handlers/
ā ā āāā mod.rs
ā ā āāā instantiate.rs
ā ā āāā execute.rs
ā ā āāā query.rs
ā ā āāā migrate.rs
ā āāā bin/
ā āāā schema.rs
ā āāā publish.rs
ā āāā install.rs
āāā tests/
āāā integration.rs
Add extra layers only when they clarify boundaries.
Current repository layers include:
domain/ for explicit business concepts and invariantsservices/ for orchestration and environment-aware compositiongateway/ for external module interaction and protocol I/Oqueries/ for query string / payload buildersreplies/ for reply handlersaxone-gov is the reference example for the richer layered shape.
msg.rs defines the public contract surface.contract.rs wires the AppContract entrypoints and module metadata.handlers/ should stay thin: decode messages, call domain/services, build responses.domain/ should own invariants and canonical representations.services/ should coordinate enriched flows or external calls without becoming a second handler layer.gateway/ should isolate external query / module plumbing.state.rs should persist and reconstruct values, not silently redefine business rules.lib.rs PatternKeep module identity constants explicit:
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");
contract.rs PatternThe baseline AppContract wiring looks like this:
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);
Repository-specific refinements:
Some(APP_METADATA_URL) when the contract publishes metadata from a tagged GitHub URL..with_replies(...) when the contract has reply-driven flows..with_dependencies(&[]) explicit unless real module dependencies exist.DependencyCreation impl when the interface needs the standard installation path used in this repo.Use abstract_app::app_msg_types!(...) in msg.rs when following the repository's Abstract app pattern.
Keep message docs and response typing aligned with:
api-designapi-doc-commentsError enums should include the standard conversion layers used by the contract and then domain-specific errors.
Do not hide domain invariants in generic StdError messages if a dedicated error variant would make the failure explicit.
Two patterns matter in this repository:
metadata.json is part of the contract deliverable and should stay aligned with the module identity.Treat both as first-class contract structure, not optional afterthoughts.
new, try_new, or from_state.