cosmos-sdk/x/auth/tx
2023-03-06 18:17:24 +00:00
..
config refactor(x/tx): Move textual,aminojson to signing (#15278) 2023-03-06 18:17:24 +00:00
testutil chore: remove gosec fork (#14752) 2023-01-24 15:09:10 +00:00
aux_test.go chore: lint tests (#14268) 2022-12-18 23:48:31 +00:00
builder_test.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
builder.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
config_test.go docs: add docs about x/auth/tx (#14021) 2022-11-27 20:30:23 +00:00
config.go refactor(x/tx): Move textual,aminojson to signing (#15278) 2023-03-06 18:17:24 +00:00
decoder.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
direct_aux_test.go refactor: don't break SignModeHandler API (#14087) 2022-12-01 16:20:10 +01:00
direct_aux.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
direct_test.go refactor: don't break SignModeHandler API (#14087) 2022-12-01 16:20:10 +01:00
direct.go refactor: don't break SignModeHandler API (#14087) 2022-12-01 16:20:10 +01:00
encode_decode_test.go fix: correct path required proto testdata (#14991) 2023-02-11 16:59:16 +00:00
encoder.go refactor: migrate to cosmos/gogoproto (#13070) 2022-09-08 17:27:48 +00:00
legacy_amino_json_test.go chore: lint tests (#14268) 2022-12-18 23:48:31 +00:00
legacy_amino_json.go refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
mode_handler.go refactor(x/tx): Move textual,aminojson to signing (#15278) 2023-03-06 18:17:24 +00:00
query.go chore: bump cometbft to v0.37.0-rc3 (#15220) 2023-03-01 16:30:41 +01:00
README.md feat: Integrate tendermint Block endpoints into the cli (#14659) 2023-02-14 19:23:45 +01:00
service.go refactor: Refactor TxSearch (#14758) 2023-02-24 16:08:53 +00:00
sigs_test.go x/auth/ante: Migrate tests to use the new client.TxConfig (#6661) 2020-07-20 08:30:12 -04:00
sigs.go docs: remove typos and IBC documentation (#11933) 2022-05-12 14:02:57 +02:00
textual.go refactor(x/tx): Move textual,aminojson to signing (#15278) 2023-03-06 18:17:24 +00:00

sidebar_position
1

x/auth/tx

:::note

Pre-requisite Readings

:::

Abstract

This document specifies the x/auth/tx package of the Cosmos SDK.

This package represents the Cosmos SDK implementation of the client.TxConfig, client.TxBuilder, client.TxEncoder and client.TxDecoder interfaces.

Contents

Transactions

TxConfig

client.TxConfig defines an interface a client can utilize to generate an application-defined concrete transaction type. The interface defines a set of methods for creating a client.TxBuilder.

https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/client/tx_config.go#L25-L31

The default implementation of client.TxConfig is instantiated by NewTxConfig in x/auth/tx module.

https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/x/auth/tx/config.go#L22-L28

TxBuilder

https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/client/tx_config.go#L33-L50

The client.TxBuilder interface is as well implemented by x/auth/tx. A client.TxBuilder can be accessed with TxConfig.NewTxBuilder().

TxEncoder/ TxDecoder

More information about TxEncoder and TxDecoder can be found here.

Client

CLI

Query

The x/auth/tx module provides a CLI command to query any transaction, given its hash, transaction sequence or signature.

Without any argument, the command will query the transaction using the transaction hash.

simd query tx DFE87B78A630C0EFDF76C80CD24C997E252792E0317502AE1A02B9809F0D8685

When querying a transaction from an account given its sequence, use the --type=acc_seq flag:

simd query tx --type=acc_seq cosmos1u69uyr6v9qwe6zaaeaqly2h6wnedac0xpxq325/1

When querying a transaction given its signature, use the --type=signature flag:

simd query tx --type=signature Ofjvgrqi8twZfqVDmYIhqwRLQjZZ40XbxEamk/veH3gQpRF0hL2PH4ejRaDzAX+2WChnaWNQJQ41ekToIi5Wqw==

When querying a transaction given its events, use the --type=events flag:

simd query txs --events 'message.sender=cosmos...' --page 1 --limit 30

The x/auth/block module provides a CLI command to query any block, given its hash, height, or events.

When querying a block by its hash, use the --type=hash flag:

simd query block --type=hash DFE87B78A630C0EFDF76C80CD24C997E252792E0317502AE1A02B9809F0D8685

When querying a block by its height, use the --type=height flag:

simd query block --type=height 1357

When querying a block by its events, use the --query flag:

simd query blocks --query 'message.sender=cosmos...' --page 1 --limit 30

Transactions

The x/auth/tx module provides a convinient CLI command for decoding and encoding transactions.

encode

The encode command encodes a transaction created with the --generate-only flag or signed with the sign command. The transaction is seralized it to Protobuf and returned as base64.

$ simd tx encode tx.json
Co8BCowBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEmwKLWNvc21vczFsNnZzcWhoN3Jud3N5cjJreXozampnM3FkdWF6OGd3Z3lsODI3NRItY29zbW9zMTU4c2FsZHlnOHBteHU3Znd2dDBkNng3amVzd3A0Z3d5a2xrNnkzGgwKBXN0YWtlEgMxMDASBhIEEMCaDA==
$ simd tx encode tx.signed.json

More information about the encode command can be found running simd tx encode --help.

decode

The decode commands decodes a transaction encoded with the encode command.

simd tx decode Co8BCowBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEmwKLWNvc21vczFsNnZzcWhoN3Jud3N5cjJreXozampnM3FkdWF6OGd3Z3lsODI3NRItY29zbW9zMTU4c2FsZHlnOHBteHU3Znd2dDBkNng3amVzd3A0Z3d5a2xrNnkzGgwKBXN0YWtlEgMxMDASBhIEEMCaDA==

More information about the decode command can be found running simd tx decode --help.

gRPC

A user can query the x/auth/tx module using gRPC endpoints.

TxDecode

The TxDecode endpoint allows to decode a transaction.

cosmos.tx.v1beta1.Service/TxDecode

Example:

grpcurl -plaintext \
    -d '{"tx_bytes":"Co8BCowBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEmwKLWNvc21vczFsNnZzcWhoN3Jud3N5cjJreXozampnM3FkdWF6OGd3Z3lsODI3NRItY29zbW9zMTU4c2FsZHlnOHBteHU3Znd2dDBkNng3amVzd3A0Z3d5a2xrNnkzGgwKBXN0YWtlEgMxMDASBhIEEMCaDA=="}' \
    localhost:9090 \
    cosmos.tx.v1beta1.Service/TxDecode

Example Output:

{
  "tx": {
    "body": {
      "messages": [
        {"@type":"/cosmos.bank.v1beta1.MsgSend","amount":[{"denom":"stake","amount":"100"}],"fromAddress":"cosmos1l6vsqhh7rnwsyr2kyz3jjg3qduaz8gwgyl8275","toAddress":"cosmos158saldyg8pmxu7fwvt0d6x7jeswp4gwyklk6y3"}
      ]
    },
    "authInfo": {
      "fee": {
        "gasLimit": "200000"
      }
    }
  }
}

TxEncode

The TxEncode endpoint allows to encode a transaction.

cosmos.tx.v1beta1.Service/TxEncode

Example:

grpcurl -plaintext \
    -d '{"tx": {
    "body": {
      "messages": [
        {"@type":"/cosmos.bank.v1beta1.MsgSend","amount":[{"denom":"stake","amount":"100"}],"fromAddress":"cosmos1l6vsqhh7rnwsyr2kyz3jjg3qduaz8gwgyl8275","toAddress":"cosmos158saldyg8pmxu7fwvt0d6x7jeswp4gwyklk6y3"}
      ]
    },
    "authInfo": {
      "fee": {
        "gasLimit": "200000"
      }
    }
  }}' \
    localhost:9090 \
    cosmos.tx.v1beta1.Service/TxEncode

Example Output:

{
  "txBytes": "Co8BCowBChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEmwKLWNvc21vczFsNnZzcWhoN3Jud3N5cjJreXozampnM3FkdWF6OGd3Z3lsODI3NRItY29zbW9zMTU4c2FsZHlnOHBteHU3Znd2dDBkNng3amVzd3A0Z3d5a2xrNnkzGgwKBXN0YWtlEgMxMDASBhIEEMCaDA=="
}

TxDecodeAmino

The TxDecode endpoint allows to decode an amino transaction.

cosmos.tx.v1beta1.Service/TxDecodeAmino

Example:

grpcurl -plaintext \
    -d '{"amino_binary": "KCgWqQpvqKNhmgotY29zbW9zMXRzeno3cDJ6Z2Q3dnZrYWh5ZnJlNHduNXh5dTgwcnB0ZzZ2OWg1Ei1jb3Ntb3MxdHN6ejdwMnpnZDd2dmthaHlmcmU0d241eHl1ODBycHRnNnY5aDUaCwoFc3Rha2USAjEwEhEKCwoFc3Rha2USAjEwEMCaDCIGZm9vYmFy"}' \
    localhost:9090 \
    cosmos.tx.v1beta1.Service/TxDecodeAmino

Example Output:

{
  "aminoJson": "{\"type\":\"cosmos-sdk/StdTx\",\"value\":{\"msg\":[{\"type\":\"cosmos-sdk/MsgSend\",\"value\":{\"from_address\":\"cosmos1tszz7p2zgd7vvkahyfre4wn5xyu80rptg6v9h5\",\"to_address\":\"cosmos1tszz7p2zgd7vvkahyfre4wn5xyu80rptg6v9h5\",\"amount\":[{\"denom\":\"stake\",\"amount\":\"10\"}]}}],\"fee\":{\"amount\":[{\"denom\":\"stake\",\"amount\":\"10\"}],\"gas\":\"200000\"},\"signatures\":null,\"memo\":\"foobar\",\"timeout_height\":\"0\"}}"
}

TxEncodeAmino

The TxEncodeAmino endpoint allows to encode an amino transaction.

cosmos.tx.v1beta1.Service/TxEncodeAmino

Example:

grpcurl -plaintext \
    -d '{"amino_json":"{\"type\":\"cosmos-sdk/StdTx\",\"value\":{\"msg\":[{\"type\":\"cosmos-sdk/MsgSend\",\"value\":{\"from_address\":\"cosmos1tszz7p2zgd7vvkahyfre4wn5xyu80rptg6v9h5\",\"to_address\":\"cosmos1tszz7p2zgd7vvkahyfre4wn5xyu80rptg6v9h5\",\"amount\":[{\"denom\":\"stake\",\"amount\":\"10\"}]}}],\"fee\":{\"amount\":[{\"denom\":\"stake\",\"amount\":\"10\"}],\"gas\":\"200000\"},\"signatures\":null,\"memo\":\"foobar\",\"timeout_height\":\"0\"}}"}' \
    localhost:9090 \
    cosmos.tx.v1beta1.Service/TxEncodeAmino

Example Output:

{
  "amino_binary": "KCgWqQpvqKNhmgotY29zbW9zMXRzeno3cDJ6Z2Q3dnZrYWh5ZnJlNHduNXh5dTgwcnB0ZzZ2OWg1Ei1jb3Ntb3MxdHN6ejdwMnpnZDd2dmthaHlmcmU0d241eHl1ODBycHRnNnY5aDUaCwoFc3Rha2USAjEwEhEKCwoFc3Rha2USAjEwEMCaDCIGZm9vYmFy"
}