cosmpy.tx package — cosmpy documentation

# cosmpy.tx package

## Submodules

## cosmpy.tx.interface module

Interface for the Tx functionality of CosmosSDK.

class cosmpy.tx.interface.TxInterface

  Bases: `abc.ABC`

  Tx abstract class.

  abstract BroadcastTx(request: cosmos.tx.v1beta1.service_pb2.BroadcastTxRequest) → cosmos.tx.v1beta1.service_pb2.BroadcastTxResponse

    BroadcastTx broadcast transaction.

  abstract GetTx(request: cosmos.tx.v1beta1.service_pb2.GetTxRequest) → cosmos.tx.v1beta1.service_pb2.GetTxResponse

    GetTx fetches a tx by hash.

  abstract GetTxsEvent(request: cosmos.tx.v1beta1.service_pb2.GetTxsEventRequest) → cosmos.tx.v1beta1.service_pb2.GetTxsEventResponse

    GetTxsEvent fetches txs by event.

  abstract Simulate(request: cosmos.tx.v1beta1.service_pb2.SimulateRequest) → cosmos.tx.v1beta1.service_pb2.SimulateResponse

    Simulate executing a transaction to estimate gas usage.

## cosmpy.tx.rest_client module

Implementation of Tx interface using REST.

class cosmpy.tx.rest_client.TxRestClient(rest_client: cosmpy.common.rest_client.RestClient)

  Bases: `cosmpy.tx.interface.TxInterface`

  Tx REST client.

  API_URL = '/cosmos/tx/v1beta1'
  BroadcastTx(request: cosmos.tx.v1beta1.service_pb2.BroadcastTxRequest) → cosmos.tx.v1beta1.service_pb2.BroadcastTxResponse

    BroadcastTx broadcast transaction.

    Parameters

      request – BroadcastTxRequest

    Returns

      BroadcastTxResponse

  GetTx(request: cosmos.tx.v1beta1.service_pb2.GetTxRequest) → cosmos.tx.v1beta1.service_pb2.GetTxResponse

    GetTx fetches a tx by hash.

    Parameters

      request – GetTxRequest

    Returns

      GetTxResponse

  GetTxsEvent(request: cosmos.tx.v1beta1.service_pb2.GetTxsEventRequest) → cosmos.tx.v1beta1.service_pb2.GetTxsEventResponse

    GetTxsEvent fetches txs by event.

    Parameters

      request – GetTxsEventRequest

    Returns

      GetTxsEventResponse

  Simulate(request: cosmos.tx.v1beta1.service_pb2.SimulateRequest) → cosmos.tx.v1beta1.service_pb2.SimulateResponse

    Simulate executing a transaction to estimate gas usage.

    Parameters

      request – SimulateRequest

    Returns

      SimulateResponse

## Module contents

This package contains the Tx modules.

cosmpy.tx.sign_transaction(tx: cosmos.tx.v1beta1.tx_pb2.Tx, signer: cosmpy.crypto.interface.Signer, chain_id: str, account_number: int, deterministic: bool = False)

  Sign transaction

  Parameters

    - tx – Transaction to be signed

    - signer – Signer of transaction

    - chain_id – Chain ID

    - account_number – Account Number

    - deterministic – Deterministic mode flag