WebAssembly

API

class terra_sdk.client.lcd.api.wasm.WasmAPI(c)[source]
code_info(code_id)[source]

Fetches information about an uploaded code.

Parameters

code_id (int) – code ID

Returns

code information

Return type

dict

contract_info(contract_address)[source]

Fetches information about an instantiated contract.

Parameters

contract_address (str) – contract address

Returns

contract information

Return type

dict

contract_query(contract_address, query_msg)[source]

Runs a QueryMsg on a contract.

Parameters
  • contract_address (str) – contract address

  • query (dict) – QueryMsg to run

Returns

results of query

Return type

Any

parameters()[source]

Fetches the Wasm module parameters.

Returns

Wasm module parameters

Return type

dict

Functions

Wasm module messages.

Messages

Wasm module messages.

class terra_sdk.core.wasm.msgs.MsgClearContractAdmin(admin, contract)[source]

Clears the contract’s admin field.

Parameters
  • admin (NewType()(AccAddress, str)) – address of current admin (sender)

  • contract (NewType()(AccAddress, str)) – address of contract to change

type_amino = 'wasm/MsgClearContractAdmin'
type_url: str = '/terra.wasm.v1beta1.MsgClearContractAdmin'
class terra_sdk.core.wasm.msgs.MsgExecuteContract(sender, contract, execute_msg, coins=NOTHING)[source]

Execute a state-mutating function on a smart contract.

Parameters
  • sender (NewType()(AccAddress, str)) – address of sender

  • contract (NewType()(AccAddress, str)) – address of contract to execute function on

  • execute_msg (dict) – ExecuteMsg to pass

  • coins (Union[Iterable[Coin], str, Dict[str, Union[str, int, float, Decimal, Dec]], Dict[str, Coin], None]) – coins to be sent, if needed by contract to execute. Defaults to empty Coins()

type_amino = 'wasm/MsgExecuteContract'
type_url: str = '/terra.wasm.v1beta1.MsgExecuteContract'
class terra_sdk.core.wasm.msgs.MsgInstantiateContract(sender, admin, code_id, init_msg, init_coins=NOTHING)[source]

Creates a new instance of a smart contract from existing code on the blockchain.

Parameters
  • sender (NewType()(AccAddress, str)) – address of sender

  • admin (Optional[NewType()(AccAddress, str)]) – address of contract admin

  • code_id (int) – code ID to use for instantiation

  • init_msg (dict) – InitMsg to initialize contract

  • init_coins (Coins) – initial amount of coins to be sent to contract

to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

type_amino = 'wasm/MsgInstantiateContract'
type_url: str = '/terra.wasm.v1beta1.MsgInstantiateContract'
class terra_sdk.core.wasm.msgs.MsgMigrateCode(sender, code_id, wasm_byte_code)[source]

Upload a new smart contract WASM binary to the blockchain, replacing an existing code ID. Can only be called once by creator of the contract, and is used for migrating from Col-4 to Col-5.

Parameters
  • sender (NewType()(AccAddress, str)) – address of sender

  • code_id – reference to the code on the blockchain

  • wasm_byte_code – base64-encoded string containing bytecode

to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

type_amino = 'wasm/MsgMigrateCode'
type_url: str = '/terra.wasm.v1beta1.MsgMigrateCode'
class terra_sdk.core.wasm.msgs.MsgMigrateContract(admin, contract, new_code_id, migrate_msg)[source]

Migrate the contract to a different code ID.

Parameters
  • admin (NewType()(AccAddress, str)) – address of contract admin

  • contract (NewType()(AccAddress, str)) – address of contract to migrate

  • new_code_id (int) – new code ID to migrate to

  • migrate_msg (dict) – MigrateMsg to execute

to_data()[source]

Converts the object to its JSON-serializable Python data representation.

Return type

dict

type_amino = 'wasm/MsgMigrateContract'
type_url: str = '/terra.wasm.v1beta1.MsgMigrateContract'
class terra_sdk.core.wasm.msgs.MsgStoreCode(sender, wasm_byte_code)[source]

Upload a new smart contract WASM binary to the blockchain.

Parameters
  • sender (NewType()(AccAddress, str)) – address of sender

  • wasm_byte_code (str) – base64-encoded string containing bytecode

type_amino = 'wasm/MsgStoreCode'
type_url: str = '/terra.wasm.v1beta1.MsgStoreCode'
class terra_sdk.core.wasm.msgs.MsgUpdateContractAdmin(admin, new_admin, contract)[source]

Update a smart contract’s admin.

Parameters
  • admin (NewType()(AccAddress, str)) – address of current admin (sender)

  • new_admin (NewType()(AccAddress, str)) – address of new admin

  • contract (NewType()(AccAddress, str)) – address of contract to change

type_amino = 'wasm/MsgUpdateContractAdmin'
type_url: str = '/terra.wasm.v1beta1.MsgUpdateContractAdmin'