Andromeda
ADO LibraryBuild AppsDevelop ADOsCLIWeb Application Docs
Andromeda
Andromeda
  • Platform and Framework
    • Introduction to AndromedaOS
    • ADO Classes
    • Andromeda Messaging Protocol
      • Kernel
      • ADO Database
      • Economics Engine
      • Virtual File System
    • ADO Base
      • AndromedaMsg
      • AndromedaQuery
    • Common Types
    • Deployed Contracts
    • ADO Versions
  • Andromeda Digital Objects
    • Introduction to ADOs
    • Address List
    • Auction
    • App
    • Curve
    • CW20
    • CW20 Staking
    • CW721
    • CW20 Exchange
    • Fixed Amount Splitter
    • Graph
    • Lockdrop
    • Marketplace
    • Merkle-Airdrop
    • Point
    • Primitive
    • Rates
    • Splitter
    • Timelock
    • Validator Staking
    • Vesting
  • Andromeda Apps
    • Introduction to Apps
    • Auctioning App
    • Cw20 Staking App
    • Marketplace App
  • Developing an ADO
    • Getting Started
      • Instantiation
      • Execution
      • Queries
      • Testing
    • Error Handling and Migrate Function
    • CW3 EXAMPLE
      • InstantiateMsg
      • ExecuteMsg
      • QueryMsg
      • Testing
    • ADO Submissions
  • Andromeda CLI
    • Introduction
    • Help and Shortcuts
    • ADO
    • Bank
    • Chain
    • Env
    • Gql
    • Tx
    • OS
    • Wallet
    • Wasm
    • Clearing CLI Data
    • Clear and Exit
  • Chain
    • Running a Node
    • Staking and Rewards
  • Andromeda Dashboard
    • Tokenomics Dashboard
    • Dashboard API
  • Andromeda Changelog
    • Newest Releases
  • Additional Resources
    • GitHub
    • Website
    • White Paper
Powered by GitBook

Additional Resources

  • Github
  • Website

Community

  • Discord
  • Telegram

Socials

  • Twitter
  • Medium
  • Youtube
On this page
  • Initial Setup
  • Building the ADO
  • Local Error Types
  • Migrate Function

Was this helpful?

  1. Developing an ADO

CW3 EXAMPLE

PreviousError Handling and Migrate FunctionNextInstantiateMsg

Last updated 2 months ago

Was this helpful?

In this example, we will be looking at transforming the cw3 from the cw-plus repo to a fixed multisig ADO. The final result can be found .

Initial Setup

The easiest and most recommended way of starting development on any ADO is to use the . From the template, we can start a new project by running the following in the terminal:

cargo generate --git https://github.com/andromedaprotocol/andr-cw-template.git --name fixed-multisig -d minimal=true

You will notice that the ADO name will be the taken from the specified name of the project by default:

For naming an ADO, try to conform with our naming standard which uses a - to separate the name in case the name is made of several words.

contract.rs
// version info for migration info
const CONTRACT_NAME: &str = "crates.io:fixed-multisig";
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

In the Cargo.toml file, you can check the version of your imported crates. The latest version of andromeda-std is "0.1.2" so make sure you update it in case another version is being used:

Cargo.toml
andromeda-std = { version = "0.1.2" }

Building the ADO

Now that you are set up with the template, you can start filling in the messages for the ADO. Since we already have most of the logic from the cw3 fixed multisig, we can just move them to our ADO template.

Local Error Types

To create a new error type, you can use the error.rs file as in any Cosmwasm contract. Since our ADO template implements a lot of functionality imported by the andromeda-std crate, we will need to wrap the andromeda error types to be included in our error.rs file.

This is already present in the template.

In the error.rs file include the following:

use andromeda_std::error::ContractError as AndrContractError;

Then we wrap it into our ContractError enum like so:

pub enum ContractError {
    #[error("{0}")]
    Std(#[from] StdError),

    #[error("{0}")]
    Andr(#[from] AndrContractError),
        .
        .
        .
    }

Migrate Function

All our ADOs contain the following migrate function to be able to migrate an ADO to a new code_id:

This will be added to our template, but if not found at the time you go through this, make sure to add it.

This can be imported and added into your ADO like so:

///Import the message
use andromeda_std::{ado_base::{MigrateMsg}},
    
    
/// Add it to the ADO
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
    ADOContract::default().migrate(deps, env, CONTRACT_NAME, CONTRACT_VERSION)
}

Other than what we have covered, most of the logic of the CW3 remained the same. Unit test and integration tests were not changed as they are already written and all passed in the ADO version as well. As mentioned , we do provide custom mock structs for testing. You can check any of our published ADOs testing from our to see how these structs can be used to conduct testing.

fixed multisig contract
here
Andromeda ADO Template
core repo
before