Transactions

API

class terra_sdk.client.lcd.api.tx.TxAPI(c)[source]
broadcast(tx)[source]

Broadcasts a transaction using the block broadcast mode.

Parameters

tx (StdTx) – transaction to broadcast

Returns

result

Return type

BlockTxBroadcastResult

broadcast_async(tx)[source]

Broadcasts a transaction using the async broadcast mode.

Parameters

tx (StdTx) – transaction to broadcast

Returns

result

Return type

AsyncTxBroadcastResult

broadcast_sync(tx)[source]

Broadcasts a transaction using the sync broadcast mode.

Parameters

tx (StdTx) – transaction to broadcast

Returns

result

Return type

SyncTxBroadcastResult

create(source_address, msgs, fee=None, memo='', gas_prices=None, gas_adjustment=None, fee_denoms=None, account_number=None, sequence=None)[source]

Create a new unsigned transaction, with helpful utilities such as lookup of chain ID, account number, sequence and fee estimation.

Parameters
  • source_address (AccAddress) – transaction sender’s account address

  • msgs (List[Msg]) – list of messages to include

  • fee (Optional[StdFee], optional) – fee to use (estimates if empty).

  • memo (str, optional) – memo to use. Defaults to “”.

  • gas_prices (Optional[Coins.Input], optional) – gas prices for fee estimation.

  • gas_adjustment (Optional[Numeric.Input], optional) – gas adjustment for fee estimation.

  • fee_denoms (Optional[List[str]], optional) – list of denoms to use for gas fee when estimating.

  • account_number (Optional[int], optional) – account number to use.

  • sequence (Optional[int], optional) – sequence number to use.

Returns

unsigned tx

Return type

StdSignMsg

encode(tx)[source]

Fetches a transaction’s amino encoding.

Parameters

tx (StdTx) – transaction to encode

Returns

base64 string containing amino-encoded tx

Return type

str

estimate_fee(tx, gas_prices=None, gas_adjustment=None, fee_denoms=None)[source]

Estimates the proper fee to apply by simulating it within the node.

Parameters
  • tx (Union[StdSignMsg, StdTx]) – transaction to estimate fee for

  • gas_prices (Optional[Coins.Input], optional) – gas prices to use.

  • gas_adjustment (Optional[Numeric.Input], optional) – gas adjustment to use.

  • fee_denoms (Optional[List[str]], optional) – list of denoms to use to pay for gas.

Returns

estimated fee

Return type

StdFee

hash(tx)[source]

Compute hash for a transaction.

Parameters

tx (StdTx) – transaction to hash

Returns

transaction hash

Return type

str

search(options={})[source]

Searches for transactions given critera.

Parameters

options (dict, optional) – dictionary containing options. Defaults to {}.

Returns

transaction search results

Return type

dict

tx_info(tx_hash)[source]

Fetches information for an included transaction given a tx hash.

Parameters

tx_hash (str) – hash of transaction to lookup

Returns

transaction info

Return type

TxInfo

Functions

terra_sdk.core.broadcast.is_tx_error(result)[source]

Returns whether the transaction failed.

Data

Transaction broadcast result data types.

class terra_sdk.core.broadcast.AsyncTxBroadcastResult(height, txhash)[source]

Data object that contains the response result from node after transaction has been broadcasted with the sync broadcast mode.

height: int

Height at which transaction was included.

txhash: str

Transaction hash.

class terra_sdk.core.broadcast.BlockTxBroadcastResult(height, txhash, raw_log, gas_wanted, gas_used, logs, code=None, codespace=None)[source]

Data object that contains the response result from node after transaction has been broadcasted with the block broadcast mode.

code: Optional[int]

If this is present, the transaction failed.

codespace: Optional[str]

used alongside code.

Type

Error subspace name

gas_used: int

Actual amount of gas consumed by transaction.

gas_wanted: int

Gas requested by the transaction.

height: int

Height at which transaction was included.

logs: Optional[List[terra_sdk.core.auth.data.tx.TxLog]]

List of transaction logs.

raw_log: Optional[str]

Raw JSON of transaction events.

txhash: str

Transaction hash.

class terra_sdk.core.broadcast.SyncTxBroadcastResult(height, txhash, raw_log, code=None, codespace=None)[source]

Data object that contains the response result from node after transaction has been broadcasted with the sync broadcast mode.

code: Optional[int]

If this is present, the transaction failed.

codespace: Optional[str]

used alongside code.

Type

Error subspace name

height: int

Height at which transaction was included.

raw_log: Optional[str]

Raw JSON of transaction events.

txhash: str

Transaction hash.