Skip to main content
logo

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.

tx.proto
Copy

_15
service Msg {
_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);
_15
}

MsgStoreCode

MsgStoreCode submit Wasm code to the system.

tx.proto
Copy

_11
message MsgStoreCode {
_11
// Sender is the that actor that signed the messages
_11
string sender = 1;
_11
// WASMByteCode can be raw or gzip compressed
_11
bytes wasm_byte_code = 2 [ (gogoproto.customname) = "WASMByteCode" ];
_11
// Used in v1beta1
_11
reserved 3, 4;
_11
// InstantiatePermission access control to apply on contract creation,
_11
// optional
_11
AccessConfig instantiate_permission = 5;
_11
}

MsgStoreCodeResponse

MsgStoreCodeResponse returns store result data.

tx.proto
Copy

_4
message MsgStoreCodeResponse {
_4
// CodeID is the reference to the stored WASM code
_4
uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
_4
}

MsgInstantiateContract

MsgInstantiateContract create a new smart contract instance for the given code id.

tx.proto
Copy

_17
message MsgInstantiateContract {
_17
// Sender is the that actor that signed the messages
_17
string sender = 1;
_17
// Admin is an optional address that can execute migrations
_17
string admin = 2;
_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
string label = 4;
_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"
_17
];
_17
}

MsgInstantiateContractResponse

MsgInstantiateContractResponse return instantiation result data.

tx.proto
Copy

_6
message MsgInstantiateContractResponse {
_6
// Address is the bech32 address of the new contract instance.
_6
string address = 1;
_6
// Data contains base64-encoded bytes to returned from the contract
_6
bytes data = 2;
_6
}

MsgExecuteContract

MsgExecuteContract submits the given message data to a smart contract.

tx.proto
Copy

_13
message MsgExecuteContract {
_13
// Sender is the that actor that signed the messages
_13
string sender = 1;
_13
// Contract is the address of the smart contract
_13
string contract = 2;
_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"
_13
];
_13
}

MsgExecuteContractResponse

MsgExecuteContractResponse returns execution result data.

tx.proto
Copy

_4
message MsgExecuteContractResponse {
_4
// Data contains base64-encoded bytes to returned from the contract
_4
bytes data = 1;
_4
}

MsgMigrateContract

MsgMigrateContract runs a code upgrade/downgrade for a smart contract.

tx.proto
Copy

_10
message MsgMigrateContract {
_10
// Sender is the that actor that signed the messages
_10
string sender = 1;
_10
// Contract is the address of the smart contract
_10
string contract = 2;
_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" ];
_10
}

MsgMigrateContractResponse

MsgMigrateContractResponse returns contract migration result data.

tx.proto
Copy

_5
message MsgMigrateContractResponse {
_5
// Data contains same raw bytes returned as data from the wasm contract.
_5
// (May be empty)
_5
bytes data = 1;
_5
}

MsgUpdateAdmin

MsgUpdateAdmin sets a new admin for a smart contract.

tx.proto
Copy

_8
message MsgUpdateAdmin {
_8
// Sender is the that actor that signed the messages
_8
string sender = 1;
_8
// NewAdmin address to be set
_8
string new_admin = 2;
_8
// Contract is the address of the smart contract
_8
string contract = 3;
_8
}

MsgUpdateAdminResponse

MsgUpdateAdminResponse returns empty data.

tx.proto
Copy

_1
message MsgUpdateAdminResponse {}

MsgClearAdmin

MsgClearAdmin removes any admin stored for a smart contract.

tx.proto
Copy

_6
message MsgClearAdmin {
_6
// Sender is the that actor that signed the messages
_6
string sender = 1;
_6
// Contract is the address of the smart contract
_6
string contract = 3;
_6
}

MsgClearAdminResponse

MsgClearAdminResponse returns empty data.

tx.proto
Copy

_1
message MsgClearAdminResponse {}

Proposal Types

StoreCodeProposal

StoreCodeProposal gov proposal content type to submit WASM code to the system.

proposal.proto
Copy

_14
message StoreCodeProposal {
_14
// Title is a short summary
_14
string title = 1;
_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
string run_as = 3;
_14
// WASMByteCode can be raw or gzip compressed
_14
bytes wasm_byte_code = 4 [ (gogoproto.customname) = "WASMByteCode" ];
_14
// Used in v1beta1
_14
reserved 5, 6;
_14
// InstantiatePermission to apply on contract creation, optional
_14
AccessConfig instantiate_permission = 7;
_14
}

InstantiateContractProposal

InstantiateContractProposal gov proposal content type to instantiate a contract.

proposal.proto
Copy

_21
message InstantiateContractProposal {
_21
// Title is a short summary
_21
string title = 1;
_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
string run_as = 3;
_21
// Admin is an optional address that can execute migrations
_21
string admin = 4;
_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
string label = 6;
_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"
_21
];
_21
}

MigrateContractProposal

MigrateContractProposal gov proposal content type to migrate a contract.

proposal.proto
Copy

_14
message MigrateContractProposal {
_14
// Title is a short summary
_14
string title = 1;
_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
_14
// Contract is the address of the smart contract
_14
string contract = 4;
_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" ];
_14
}

SudoContractProposal

SudoContractProposal gov proposal content type to call sudo on a contract.

proposal.proto
Copy

_10
message SudoContractProposal {
_10
// Title is a short summary
_10
string title = 1;
_10
// Description is a human readable text
_10
string description = 2;
_10
// Contract is the address of the smart contract
_10
string contract = 3;
_10
// Msg json encoded message to be passed to the contract as sudo
_10
bytes msg = 4 [ (gogoproto.casttype) = "RawContractMessage" ];
_10
}

ExecuteContractProposal

ExecuteContractProposal gov proposal content type to call execute on a contract.

proposal.proto
Copy

_17
message ExecuteContractProposal {
_17
// Title is a short summary
_17
string title = 1;
_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
string run_as = 3;
_17
// Contract is the address of the smart contract
_17
string contract = 4;
_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"
_17
];
_17
}

UpdateAdminProposal

UpdateAdminProposal gov proposal content type to set an admin for a contract.

proposal.proto
Copy

_10
message UpdateAdminProposal {
_10
// Title is a short summary
_10
string title = 1;
_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
_10
string contract = 4;
_10
}

ClearAdminProposal

ClearAdminProposal gov proposal content type to clear the admin of a contract.

proposal.proto
Copy

_8
message ClearAdminProposal {
_8
// Title is a short summary
_8
string title = 1;
_8
// Description is a human readable text
_8
string description = 2;
_8
// Contract is the address of the smart contract
_8
string contract = 3;
_8
}

PinCodesProposal

PinCodesProposal gov proposal content type to pin a set of code ids in the wasmvm cache.

proposal.proto
Copy

_11
message 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\""
_11
];
_11
}

UnpinCodesProposal

UnpinCodesProposal gov proposal content type to unpin a set of code ids in the wasmvm cache.

proposal.proto
Copy

_11
message 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\""
_11
];
_11
}

AccessConfigUpdate

AccessConfigUpdate contains the code id and the access config to be applied.

proposal.proto
Copy

_6
message 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 ];
_6
}

UpdateInstantiateConfigProposal

UpdateInstantiateConfigProposal gov proposal content type to update instantiate config to a set of code ids.

proposal.proto
Copy

_10
message 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
// to be applied.
_10
repeated AccessConfigUpdate access_config_updates = 3
_10
[ (gogoproto.nullable) = false ];
_10
}

Queries

Query provides defines the gRPC querier service.

query.proto
Copy

_48
service Query {
_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
}
_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
}
_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
}
_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
}
_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
}
_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
}
_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
}
_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
}
_48
_48
// PinnedCodes gets the pinned code ids
_48
rpc PinnedCodes(QueryPinnedCodesRequest) returns (QueryPinnedCodesResponse) {
_48
option (google.api.http).get = "/cosmwasm/wasm/v1/codes/pinned";
_48
}
_48
}

QueryContractInfoRequest

QueryContractInfoRequest is the request type for the Query/ContractInfo RPC method.

query.proto
Copy

_4
message QueryContractInfoRequest {
_4
// address is the address of the contract to query
_4
string address = 1;
_4
}

QueryContractInfoResponse

QueryContractInfoResponse is the response type for the Query/ContractInfo RPC method.

query.proto
Copy

_11
message QueryContractInfoResponse {
_11
option (gogoproto.equal) = true;
_11
_11
// address is the address of the contract
_11
string address = 1;
_11
ContractInfo contract_info = 2 [
_11
(gogoproto.embed) = true,
_11
(gogoproto.nullable) = false,
_11
(gogoproto.jsontag) = ""
_11
];
_11
}

QueryContractHistoryRequest

QueryContractHistoryRequest is the request type for the Query/ContractHistory RPC method.

query.proto
Copy

_6
message QueryContractHistoryRequest {
_6
// address is the address of the contract to query
_6
string address = 1;
_6
// pagination defines an optional pagination for the request.
_6
cosmos.base.query.v1beta1.PageRequest pagination = 2;
_6
}

QueryContractHistoryResponse

QueryContractHistoryResponse is the response type for the Query/ContractHistory RPC method.

query.proto
Copy

_6
message 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;
_6
}

QueryContractsByCodeRequest

QueryContractsByCodeRequest is the request type for the Query/ContractsByCode RPC method.

query.proto
Copy

_5
message 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;
_5
}

QueryContractsByCodeResponse

QueryContractsByCodeResponse is the response type for the Query/ContractsByCode RPC method.

query.proto
Copy

_7
message QueryContractsByCodeResponse {
_7
// contracts are a set of contract addresses
_7
repeated string contracts = 1;
_7
_7
// pagination defines the pagination in the response.
_7
cosmos.base.query.v1beta1.PageResponse pagination = 2;
_7
}

QueryAllContractStateRequest

QueryAllContractStateRequest is the request type for the Query/AllContractState RPC method.

query.proto
Copy

_6
message QueryAllContractStateRequest {
_6
// address is the address of the contract
_6
string address = 1;
_6
// pagination defines an optional pagination for the request.
_6
cosmos.base.query.v1beta1.PageRequest pagination = 2;
_6
}

QueryAllContractStateResponse

QueryAllContractStateResponse is the response type for the Query/AllContractState RPC method.

query.proto
Copy

_5
message 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;
_5
}

QueryRawContractStateRequest

QueryRawContractStateRequest is the request type for the Query/RawContractState RPC method.

query.proto
Copy

_5
message QueryRawContractStateRequest {
_5
// address is the address of the contract
_5
string address = 1;
_5
bytes query_data = 2;
_5
}

QueryRawContractStateResponse

QueryRawContractStateResponse is the response type for the Query/RawContractState RPC method.

query.proto
Copy

_4
message QueryRawContractStateResponse {
_4
// Data contains the raw store data
_4
bytes data = 1;
_4
}

QuerySmartContractStateRequest

QuerySmartContractStateRequest is the request type for the Query/SmartContractState RPC method.

query.proto
Copy

_6
message QuerySmartContractStateRequest {
_6
// address is the address of the contract
_6
string address = 1;
_6
// QueryData contains the query data passed to the contract
_6
bytes query_data = 2 [ (gogoproto.casttype) = "RawContractMessage" ];
_6
}

QuerySmartContractStateResponse

QuerySmartContractStateResponse is the response type for the Query/SmartContractState RPC method.

query.proto
Copy

_4
message QuerySmartContractStateResponse {
_4
// Data contains the json data returned from the smart contract
_4
bytes data = 1 [ (gogoproto.casttype) = "RawContractMessage" ];
_4
}

QueryCodeRequest

QueryCodeRequest is the request type for the Query/Code RPC method.

query.proto
Copy

_3
message QueryCodeRequest {
_3
uint64 code_id = 1; // grpc-gateway_out does not support Go style CodID
_3
}

QueryCodeResponse

QueryCodeResponse is the response type for the Query/Code RPC method.

query.proto
Copy

_6
message QueryCodeResponse {
_6
option (gogoproto.equal) = true;
_6
CodeInfoResponse code_info = 1
_6
[ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ];
_6
bytes data = 2 [ (gogoproto.jsontag) = "data" ];
_6
}

QueryCodesRequest

QueryCodesRequest is the request type for the Query/Codes RPC method.

query.proto
Copy

_4
message QueryCodesRequest {
_4
// pagination defines an optional pagination for the request.
_4
cosmos.base.query.v1beta1.PageRequest pagination = 1;
_4
}

QueryCodesResponse

QueryCodesResponse is the response type for the Query/Codes RPC method.

query.proto
Copy

_5
message 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;
_5
}

QueryPinnedCodesRequest

QueryPinnedCodesRequest is the request type for the Query/PinnedCodes RPC method.

query.proto
Copy

_4
message QueryPinnedCodesRequest {
_4
// pagination defines an optional pagination for the request.
_4
cosmos.base.query.v1beta1.PageRequest pagination = 2;
_4
}

QueryPinnedCodesResponse

QueryPinnedCodesResponse is the response type for the Query/PinnedCodes RPC method.

query.proto
Copy

_6
message 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;
_6
}