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 uploaded code.

Parameters

code_id (int) – code ID

Returns

code information

Return type

dict

contract_query(contract_address, query_msg)[source]

Runs a QueryMsg on a contract.

Parameters
  • contract_address (str) – contract address

  • query_msg (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.

terra_sdk.core.wasm.msgs.b64_to_dict(data)[source]

Converts ASCII-encoded base64 encoded string to dict.

Return type

dict

terra_sdk.core.wasm.msgs.dict_to_b64(data)[source]

Converts dict to ASCII-encoded base64 encoded string.

Return type

str

Messages

Wasm module messages.

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 (AccAddress) – address of sender

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

  • execute_msg (dict) – ExecuteMsg (aka. HandleMsg) to pass

  • coins – coins to be sent, if needed by contract to execute. Defaults to empty Coins()

to_data()[source]

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

Return type

dict

type: str = 'wasm/MsgExecuteContract'
class terra_sdk.core.wasm.msgs.MsgInstantiateContract(owner, code_id, init_msg, init_coins=NOTHING, migratable=False)[source]

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

Parameters
  • owner (AccAddress) – address of contract owner

  • 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

  • migratable (bool) – whether the owner can change contract code IDs

to_data()[source]

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

Return type

dict

type: str = 'wasm/MsgInstantiateContract'
class terra_sdk.core.wasm.msgs.MsgMigrateContract(owner, contract, new_code_id, migrate_msg)[source]

Migrate the contract to a different code ID.

Parameters
  • owner (AccAddress) – address of owner

  • contract (AccAddress) – 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: str = 'wasm/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 (AccAddress) – address of sender

  • wasm_byte_code – base64-encoded string containing bytecode

type: str = 'wasm/MsgStoreCode'
class terra_sdk.core.wasm.msgs.MsgUpdateContractOwner(owner, new_owner, contract)[source]

Update a smart contract’s owner.

Parameters
  • owner (AccAddress) – address of current owner (sender)

  • new_owner (AccAddress) – address of new owner

  • contract (AccAddress) – address of contract to change

type: str = 'wasm/MsgUpdateContractOwner'