#query #cosmwasm #message #module #neutron #included #standard

neutron-std

Standard library for Neutron with CosmWasm support included

1 release (0 unstable)

1.0.4-rc.1 Aug 13, 2023

#6 in #neutron

Download history 27/week @ 2024-01-03 38/week @ 2024-02-14 8/week @ 2024-02-21 9/week @ 2024-02-28 2/week @ 2024-03-06 6/week @ 2024-03-13 2/week @ 2024-03-20 8/week @ 2024-03-27 14/week @ 2024-04-03 58/week @ 2024-04-10

82 downloads per month

MIT/Apache

555KB
14K SLoC

neutron-std

neutron-std on crates.io Docs

Neutron's proto-generated types and helpers for interacting with the appchain. Compatible with CosmWasm contract.

CosmWasm stargate message and stargate query

You can find all types and querier generated from Neutron's protobuf in their respective module in neutron_std.

Executing Neutron messages from CosmWasm Contract

use cosmwasm_std::{CosmosMsg, Response, Env};
use neutron_std::types::osmosis::tokenfactory::v1beta1::MsgCreateDenom;

# type ContractError = cosmwasm_std::StdError;
// ..

pub fn try_create_denom(env: Env, subdenom: String) -> Result<Response, ContractError> {
    let sender = env.contract.address.into();

    // construct message and convert them into cosmos message
    // (notice `CosmosMsg` type and `.into()`)
    let msg_create_denom: CosmosMsg = MsgCreateDenom { sender, subdenom }.into();

    Ok(Response::new()
        .add_message(msg_create_denom)
        .add_attribute("method", "try_create_denom"))
}

Querying Neutron modules

Stargate queries are currently disabled on Neutron, but will be enabled in the future. For now, you can use the bindings in neutron-sdk crate to query Neutron modules.

Dependencies

~5–7MB
~145K SLoC