Transactions

API

class terra_sdk.client.lcd.api.tx.TxAPI(c)[source]
broadcast(tx, options=None)[source]

Broadcasts a transaction using the block broadcast mode.

Parameters
  • tx (Tx) – transaction to broadcast

  • options (BroadcastOptions) – broacast options, optional

Returns

result

Return type

BlockTxBroadcastResult

broadcast_async(tx, options=None)[source]

Broadcasts a transaction using the async broadcast mode.

Parameters
  • tx (Tx) – transaction to broadcast

  • options (BroadcastOptions) – broacast options, optional

Returns

result

Return type

AsyncTxBroadcastResult

broadcast_sync(tx, options=None)[source]

Broadcasts a transaction using the sync broadcast mode.

Parameters
  • tx (Tx) – transaction to broadcast

  • options (BroadcastOptions) – broacast options, optional

Returns

result

Return type

SyncTxBroadcastResult

create(signers, options)[source]

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

Parameters
  • signers (List[SingerOptions]) – options about signers

  • options (CreateTxOptions) – options about creating a tx

Returns

unsigned tx

Return type

Tx

decode(tx)[source]

Decode base64 encoded proto string to a Tx

Return type

Tx

encode(tx)[source]

Encode a Tx to base64 encoded proto string

Return type

str

estimate_fee(signers, options)[source]

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

Parameters
  • signers ([SignerOptions]) – signers

  • options (CreateTxOptions) – transaction info to estimate fee

Returns

estimated fee

Return type

Fee

hash(tx)[source]

Compute hash for a transaction.

Parameters

tx (Tx) – transaction to hash

Returns

transaction hash

Return type

str

search(events, params=None)[source]

Searches for transactions given criteria.

Parameters
  • events (dict) – dictionary containing options

  • params (APIParams) – optional parameters

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

tx_infos_by_height(height=None)[source]

Fetches information for an included transaction given block height or latest

Parameters

height (int, optional) – height to lookup. latest if height is None.

Returns

transaction info

Return type

List[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(txhash)[source]

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

txhash: str

Transaction hash.

class terra_sdk.core.broadcast.BlockTxBroadcastResult(height, txhash, raw_log, gas_wanted, gas_used, logs, code=None, codespace=None, info=None, data=None, timestamp=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

data: Optional[str]
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.

info: Optional[str]
logs: Optional[List[terra_sdk.core.tx.TxLog]]

List of transaction logs.

raw_log: Optional[str]

Raw JSON of transaction events.

timestamp: Optional[str]

timestamp

txhash: str

Transaction hash.

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

Data object that contains the response result from node after transactionco 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

raw_log: Optional[str]

Raw JSON of transaction events.

txhash: str

Transaction hash.