Cosm-Orc

cosm-orc on crates.io Docs

Rust Cosmwasm smart contract orchestration and gas profiling library.

Store, instantiate, execute, and query Cosmwasm smart contracts against a configured Cosmos based chain.

Optionally, profile gas usage of the smart contract operations.

Potential uses: * Integration tests * Deployments / Bootstrapping environments * Gas profiling

This project is not yet intended to be used for mainnet.

Quick Start

``rust // juno_local.yaml has thecw20basecode_id already stored // If the smart contract has not been stored on the chain yet use:cosmorc::storecontracts()` let mut cosmorc = CosmOrc::new(Config::fromyaml("./example-configs/junolocal.yaml")?)?; let key = SigningKey { name: "validator".tostring(), key: Key::Mnemonic("word1 word2 ...".tostring()), };

let msgs: Vec> = vec![ WasmMsg::InstantiateMsg(InstantiateMsg { name: "Meme Token".tostring(), symbol: "MEME".tostring(), decimals: 6, initialbalances: vec![], mint: None, marketing: None, }), WasmMsg::QueryMsg(QueryMsg::TokenInfo {}), ]; cosmorc.processmsgs("cw20base", "memetokentest", &msgs, &key)?; ```

See here for example usages.

Store Contracts

If config.yaml doesn't have the pre-stored contract code ids, you can call store_contracts(): ```rust let mut cosmorc = CosmOrc::new(Config::fromyaml("./example-configs/junolocal.yaml")?)?; let key = SigningKey { name: "validator".tostring(), key: Key::Mnemonic("word1 word2 ...".to_string()), };

// ./artifacts is a directory that contains the rust optimized wasm files. // // NOTE: currently cosm-orc is expecting a wasm filed called: cw20_base.wasm // to be in /artifacts, since cw20_base is used as the contract name in processmsgs() call below cosmorc.store_contracts("./artifacts", &key)?;

let msgs: Vec> = vec![ WasmMsg::InstantiateMsg(InstantiateMsg { name: "Meme Token".tostring(), symbol: "MEME".tostring(), decimals: 6, initialbalances: vec![], mint: None, marketing: None, }), WasmMsg::QueryMsg(QueryMsg::TokenInfo {}), ]; cosmorc.processmsgs("cw20base", "memetokentest", &msgs, &key)?; ```

Gas Profiling

```rust let mut cosmorc = CosmOrc::new(Config::fromyaml("config.yaml")?)?.add_profiler(Box::new(GasProfiler::new()));

cosmorc.processmsgs("cw20base", "memetoken_test", &msgs, &key)?;

let reports = cosmorc.profilerreports()?; ```

Configuration

See ./example-configs directory for example yaml configs.