wasm
The wasm module is responsible for handling CosmWasm smart contract functionality on Mars Hub. The module is permission-gated (contracts can only be instantiated by whitelisted addresses or through governance).
For more information, visit: https://github.com/CosmWasm/cosmwasm
Message Types
Msg
defines the wasm Msg service.
_15 // StoreCode to submit Wasm code to the system
_15 rpc StoreCode(MsgStoreCode) returns (MsgStoreCodeResponse);
_15 // Instantiate creates a new smart contract instance for the given code id.
_15 rpc InstantiateContract(MsgInstantiateContract)
_15 returns (MsgInstantiateContractResponse);
_15 // Execute submits the given message data to a smart contract
_15 rpc ExecuteContract(MsgExecuteContract) returns (MsgExecuteContractResponse);
_15 // Migrate runs a code upgrade/ downgrade for a smart contract
_15 rpc MigrateContract(MsgMigrateContract) returns (MsgMigrateContractResponse);
_15 // UpdateAdmin sets a new admin for a smart contract
_15 rpc UpdateAdmin(MsgUpdateAdmin) returns (MsgUpdateAdminResponse);
_15 // ClearAdmin removes any admin stored for a smart contract
_15 rpc ClearAdmin(MsgClearAdmin) returns (MsgClearAdminResponse);
MsgStoreCode
MsgStoreCode
submit Wasm code to the system.
_11message MsgStoreCode {
_11 // Sender is the that actor that signed the messages
_11 // WASMByteCode can be raw or gzip compressed
_11 bytes wasm_byte_code = 2 [ (gogoproto.customname) = "WASMByteCode" ];
_11 // InstantiatePermission access control to apply on contract creation,
_11 AccessConfig instantiate_permission = 5;
MsgStoreCodeResponse
MsgStoreCodeResponse
returns store result data.
_4message MsgStoreCodeResponse {
_4 // CodeID is the reference to the stored WASM code
_4 uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
MsgInstantiateContract
MsgInstantiateContract
create a new smart contract instance for the given code id.
_17message MsgInstantiateContract {
_17 // Sender is the that actor that signed the messages
_17 // Admin is an optional address that can execute migrations
_17 // CodeID is the reference to the stored WASM code
_17 uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
_17 // Label is optional metadata to be stored with a contract instance.
_17 // Msg json encoded message to be passed to the contract on instantiation
_17 bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ];
_17 // Funds coins that are transferred to the contract on instantiation
_17 repeated cosmos.base.v1beta1.Coin funds = 6 [
_17 (gogoproto.nullable) = false,
_17 (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
MsgInstantiateContractResponse
MsgInstantiateContractResponse
return instantiation result data.
_6message MsgInstantiateContractResponse {
_6 // Address is the bech32 address of the new contract instance.
_6 // Data contains base64-encoded bytes to returned from the contract
MsgExecuteContract
MsgExecuteContract
submits the given message data to a smart contract.
_13message MsgExecuteContract {
_13 // Sender is the that actor that signed the messages
_13 // Contract is the address of the smart contract
_13 // Msg json encoded message to be passed to the contract
_13 bytes msg = 3 [ (gogoproto.casttype) = "RawContractMessage" ];
_13 // Funds coins that are transferred to the contract on execution
_13 repeated cosmos.base.v1beta1.Coin funds = 5 [
_13 (gogoproto.nullable) = false,
_13 (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
MsgExecuteContractResponse
MsgExecuteContractResponse
returns execution result data.
_4message MsgExecuteContractResponse {
_4 // Data contains base64-encoded bytes to returned from the contract
MsgMigrateContract
MsgMigrateContract
runs a code upgrade/downgrade for a smart contract.
_10message MsgMigrateContract {
_10 // Sender is the that actor that signed the messages
_10 // Contract is the address of the smart contract
_10 // CodeID references the new WASM code
_10 uint64 code_id = 3 [ (gogoproto.customname) = "CodeID" ];
_10 // Msg json encoded message to be passed to the contract on migration
_10 bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ];
MsgMigrateContractResponse
MsgMigrateContractResponse
returns contract migration result data.
_5message MsgMigrateContractResponse {
_5 // Data contains same raw bytes returned as data from the wasm contract.
MsgUpdateAdmin
MsgUpdateAdmin
sets a new admin for a smart contract.
_8message MsgUpdateAdmin {
_8 // Sender is the that actor that signed the messages
_8 // NewAdmin address to be set
_8 // Contract is the address of the smart contract
MsgUpdateAdminResponse
MsgUpdateAdminResponse
returns empty data.
_1message MsgUpdateAdminResponse {}
MsgClearAdmin
MsgClearAdmin
removes any admin stored for a smart contract.
_6message MsgClearAdmin {
_6 // Sender is the that actor that signed the messages
_6 // Contract is the address of the smart contract
MsgClearAdminResponse
MsgClearAdminResponse
returns empty data.
_1message MsgClearAdminResponse {}
Proposal Types
StoreCodeProposal
StoreCodeProposal
gov proposal content type to submit WASM code to the system.
_14message StoreCodeProposal {
_14 // Title is a short summary
_14 // Description is a human readable text
_14 string description = 2;
_14 // RunAs is the address that is passed to the contract's environment as sender
_14 // WASMByteCode can be raw or gzip compressed
_14 bytes wasm_byte_code = 4 [ (gogoproto.customname) = "WASMByteCode" ];
_14 // InstantiatePermission to apply on contract creation, optional
_14 AccessConfig instantiate_permission = 7;
InstantiateContractProposal
InstantiateContractProposal
gov proposal content type to instantiate a contract.
_21message InstantiateContractProposal {
_21 // Title is a short summary
_21 // Description is a human readable text
_21 string description = 2;
_21 // RunAs is the address that is passed to the contract's environment as sender
_21 // Admin is an optional address that can execute migrations
_21 // CodeID is the reference to the stored WASM code
_21 uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
_21 // Label is optional metadata to be stored with a constract instance.
_21 // Msg json encoded message to be passed to the contract on instantiation
_21 bytes msg = 7 [ (gogoproto.casttype) = "RawContractMessage" ];
_21 // Funds coins that are transferred to the contract on instantiation
_21 repeated cosmos.base.v1beta1.Coin funds = 8 [
_21 (gogoproto.nullable) = false,
_21 (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
MigrateContractProposal
MigrateContractProposal
gov proposal content type to migrate a contract.
_14message MigrateContractProposal {
_14 // Title is a short summary
_14 // Description is a human readable text
_14 string description = 2;
_14 // Note: skipping 3 as this was previously used for unneeded run_as
_14 // Contract is the address of the smart contract
_14 // CodeID references the new WASM code
_14 uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
_14 // Msg json encoded message to be passed to the contract on migration
_14 bytes msg = 6 [ (gogoproto.casttype) = "RawContractMessage" ];
SudoContractProposal
SudoContractProposal
gov proposal content type to call sudo on a contract.
_10message SudoContractProposal {
_10 // Title is a short summary
_10 // Description is a human readable text
_10 string description = 2;
_10 // Contract is the address of the smart contract
_10 // Msg json encoded message to be passed to the contract as sudo
_10 bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ];
ExecuteContractProposal
ExecuteContractProposal
gov proposal content type to call execute on a contract.
_17message ExecuteContractProposal {
_17 // Title is a short summary
_17 // Description is a human readable text
_17 string description = 2;
_17 // RunAs is the address that is passed to the contract's environment as sender
_17 // Contract is the address of the smart contract
_17 // Msg json encoded message to be passed to the contract as execute
_17 bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ];
_17 // Funds coins that are transferred to the contract on instantiation
_17 repeated cosmos.base.v1beta1.Coin funds = 6 [
_17 (gogoproto.nullable) = false,
_17 (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
UpdateAdminProposal
UpdateAdminProposal
gov proposal content type to set an admin for a contract.
_10message UpdateAdminProposal {
_10 // Title is a short summary
_10 // Description is a human readable text
_10 string description = 2;
_10 // NewAdmin address to be set
_10 string new_admin = 3 [ (gogoproto.moretags) = "yaml:\"new_admin\"" ];
_10 // Contract is the address of the smart contract
ClearAdminProposal
ClearAdminProposal
gov proposal content type to clear the admin of a contract.
_8message ClearAdminProposal {
_8 // Title is a short summary
_8 // Description is a human readable text
_8 string description = 2;
_8 // Contract is the address of the smart contract
PinCodesProposal
PinCodesProposal
gov proposal content type to pin a set of code ids in the wasmvm cache.
_11message PinCodesProposal {
_11 // Title is a short summary
_11 string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
_11 // Description is a human readable text
_11 string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
_11 // CodeIDs references the new WASM codes
_11 repeated uint64 code_ids = 3 [
_11 (gogoproto.customname) = "CodeIDs",
_11 (gogoproto.moretags) = "yaml:\"code_ids\""
UnpinCodesProposal
UnpinCodesProposal
gov proposal content type to unpin a set of code ids in the wasmvm cache.
_11message UnpinCodesProposal {
_11 // Title is a short summary
_11 string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
_11 // Description is a human readable text
_11 string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
_11 // CodeIDs references the WASM codes
_11 repeated uint64 code_ids = 3 [
_11 (gogoproto.customname) = "CodeIDs",
_11 (gogoproto.moretags) = "yaml:\"code_ids\""
AccessConfigUpdate
AccessConfigUpdate
contains the code id and the access config to be applied.
_6message AccessConfigUpdate {
_6 // CodeID is the reference to the stored WASM code to be updated
_6 uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
_6 // InstantiatePermission to apply to the set of code ids
_6 AccessConfig instantiate_permission = 2 [ (gogoproto.nullable) = false ];
UpdateInstantiateConfigProposal
UpdateInstantiateConfigProposal
gov proposal content type to update instantiate config to a set of code ids.
_10message UpdateInstantiateConfigProposal {
_10 // Title is a short summary
_10 string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ];
_10 // Description is a human readable text
_10 string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ];
_10 // AccessConfigUpdate contains the list of code ids and the access config
_10 repeated AccessConfigUpdate access_config_updates = 3
_10 [ (gogoproto.nullable) = false ];
Queries
Query
provides defines the gRPC querier service.
_48 // ContractInfo gets the contract meta data
_48 rpc ContractInfo(QueryContractInfoRequest)
_48 returns (QueryContractInfoResponse) {
_48 option (google.api.http).get = "/cosmwasm/wasm/v1/contract/{address}";
_48 // ContractHistory gets the contract code history
_48 rpc ContractHistory(QueryContractHistoryRequest)
_48 returns (QueryContractHistoryResponse) {
_48 option (google.api.http).get =
_48 "/cosmwasm/wasm/v1/contract/{address}/history";
_48 // ContractsByCode lists all smart contracts for a code id
_48 rpc ContractsByCode(QueryContractsByCodeRequest)
_48 returns (QueryContractsByCodeResponse) {
_48 option (google.api.http).get = "/cosmwasm/wasm/v1/code/{code_id}/contracts";
_48 // AllContractState gets all raw store data for a single contract
_48 rpc AllContractState(QueryAllContractStateRequest)
_48 returns (QueryAllContractStateResponse) {
_48 option (google.api.http).get = "/cosmwasm/wasm/v1/contract/{address}/state";
_48 // RawContractState gets single key from the raw store data of a contract
_48 rpc RawContractState(QueryRawContractStateRequest)
_48 returns (QueryRawContractStateResponse) {
_48 option (google.api.http).get =
_48 "/cosmwasm/wasm/v1/contract/{address}/raw/{query_data}";
_48 // SmartContractState get smart query result from the contract
_48 rpc SmartContractState(QuerySmartContractStateRequest)
_48 returns (QuerySmartContractStateResponse) {
_48 option (google.api.http).get =
_48 "/cosmwasm/wasm/v1/contract/{address}/smart/{query_data}";
_48 // Code gets the binary code and metadata for a singe wasm code
_48 rpc Code(QueryCodeRequest) returns (QueryCodeResponse) {
_48 option (google.api.http).get = "/cosmwasm/wasm/v1/code/{code_id}";
_48 // Codes gets the metadata for all stored wasm codes
_48 rpc Codes(QueryCodesRequest) returns (QueryCodesResponse) {
_48 option (google.api.http).get = "/cosmwasm/wasm/v1/code";
_48 // PinnedCodes gets the pinned code ids
_48 rpc PinnedCodes(QueryPinnedCodesRequest) returns (QueryPinnedCodesResponse) {
_48 option (google.api.http).get = "/cosmwasm/wasm/v1/codes/pinned";
QueryContractInfoRequest
QueryContractInfoRequest
is the request type for the Query/ContractInfo
RPC method.
_4message QueryContractInfoRequest {
_4 // address is the address of the contract to query
QueryContractInfoResponse
QueryContractInfoResponse
is the response type for the Query/ContractInfo
RPC method.
_11message QueryContractInfoResponse {
_11 option (gogoproto.equal) = true;
_11 // address is the address of the contract
_11 ContractInfo contract_info = 2 [
_11 (gogoproto.embed) = true,
_11 (gogoproto.nullable) = false,
_11 (gogoproto.jsontag) = ""
QueryContractHistoryRequest
QueryContractHistoryRequest
is the request type for the Query/ContractHistory
RPC method.
_6message QueryContractHistoryRequest {
_6 // address is the address of the contract to query
_6 // pagination defines an optional pagination for the request.
_6 cosmos.base.query.v1beta1.PageRequest pagination = 2;
QueryContractHistoryResponse
QueryContractHistoryResponse
is the response type for the Query/ContractHistory
RPC method.
_6message QueryContractHistoryResponse {
_6 repeated ContractCodeHistoryEntry entries = 1
_6 [ (gogoproto.nullable) = false ];
_6 // pagination defines the pagination in the response.
_6 cosmos.base.query.v1beta1.PageResponse pagination = 2;
QueryContractsByCodeRequest
QueryContractsByCodeRequest
is the request type for the Query/ContractsByCode
RPC method.
_5message QueryContractsByCodeRequest {
_5 uint64 code_id = 1; // grpc-gateway_out does not support Go style CodID
_5 // pagination defines an optional pagination for the request.
_5 cosmos.base.query.v1beta1.PageRequest pagination = 2;
QueryContractsByCodeResponse
QueryContractsByCodeResponse
is the response type for the Query/ContractsByCode
RPC method.
_7message QueryContractsByCodeResponse {
_7 // contracts are a set of contract addresses
_7 repeated string contracts = 1;
_7 // pagination defines the pagination in the response.
_7 cosmos.base.query.v1beta1.PageResponse pagination = 2;
QueryAllContractStateRequest
QueryAllContractStateRequest
is the request type for the Query/AllContractState
RPC method.
_6message QueryAllContractStateRequest {
_6 // address is the address of the contract
_6 // pagination defines an optional pagination for the request.
_6 cosmos.base.query.v1beta1.PageRequest pagination = 2;
QueryAllContractStateResponse
QueryAllContractStateResponse
is the response type for the Query/AllContractState
RPC method.
_5message QueryAllContractStateResponse {
_5 repeated Model models = 1 [ (gogoproto.nullable) = false ];
_5 // pagination defines the pagination in the response.
_5 cosmos.base.query.v1beta1.PageResponse pagination = 2;
QueryRawContractStateRequest
QueryRawContractStateRequest
is the request type for the Query/RawContractState
RPC method.
_5message QueryRawContractStateRequest {
_5 // address is the address of the contract
QueryRawContractStateResponse
QueryRawContractStateResponse
is the response type for the Query/RawContractState
RPC method.
_4message QueryRawContractStateResponse {
_4 // Data contains the raw store data
QuerySmartContractStateRequest
QuerySmartContractStateRequest
is the request type for the Query/SmartContractState
RPC method.
_6message QuerySmartContractStateRequest {
_6 // address is the address of the contract
_6 // QueryData contains the query data passed to the contract
_6 bytes query_data = 2 [ (gogoproto.casttype) = "RawContractMessage" ];
QuerySmartContractStateResponse
QuerySmartContractStateResponse
is the response type for the Query/SmartContractState
RPC method.
_4message QuerySmartContractStateResponse {
_4 // Data contains the json data returned from the smart contract
_4 bytes data = 1 [ (gogoproto.casttype) = "RawContractMessage" ];
QueryCodeRequest
QueryCodeRequest
is the request type for the Query/Code
RPC method.
_3message QueryCodeRequest {
_3 uint64 code_id = 1; // grpc-gateway_out does not support Go style CodID
QueryCodeResponse
QueryCodeResponse
is the response type for the Query/Code
RPC method.
_6message QueryCodeResponse {
_6 option (gogoproto.equal) = true;
_6 CodeInfoResponse code_info = 1
_6 [ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ];
_6 bytes data = 2 [ (gogoproto.jsontag) = "data" ];
QueryCodesRequest
QueryCodesRequest
is the request type for the Query/Codes
RPC method.
_4message QueryCodesRequest {
_4 // pagination defines an optional pagination for the request.
_4 cosmos.base.query.v1beta1.PageRequest pagination = 1;
QueryCodesResponse
QueryCodesResponse
is the response type for the Query/Codes
RPC method.
_5message QueryCodesResponse {
_5 repeated CodeInfoResponse code_infos = 1 [ (gogoproto.nullable) = false ];
_5 // pagination defines the pagination in the response.
_5 cosmos.base.query.v1beta1.PageResponse pagination = 2;
QueryPinnedCodesRequest
QueryPinnedCodesRequest
is the request type for the Query/PinnedCodes
RPC method.
_4message QueryPinnedCodesRequest {
_4 // pagination defines an optional pagination for the request.
_4 cosmos.base.query.v1beta1.PageRequest pagination = 2;
QueryPinnedCodesResponse
QueryPinnedCodesResponse
is the response type for the Query/PinnedCodes RPC method.
_6message QueryPinnedCodesResponse {
_6 repeated uint64 code_ids = 1
_6 [ (gogoproto.nullable) = false, (gogoproto.customname) = "CodeIDs" ];
_6 // pagination defines the pagination in the response.
_6 cosmos.base.query.v1beta1.PageResponse pagination = 2;