Skip to main content

Transactions

The xyz tx command group provides transaction-related operations.

Transaction History

View recent transactions for an address:
xyz tx history <address>
Or by key name:
xyz tx history --key <name>

Example

xyz tx history --key alice
Output:
HASH                                                              HEIGHT  TYPE             TIMESTAMP
ABC123DEF456789...                                                12345   /cosmos.bank...  2024-01-29 10:30:00
DEF456789ABC123...                                                12340   /cosmwasm.wasm.. 2024-01-29 10:25:00
789ABC123DEF456...                                                12335   /cosmos.staking. 2024-01-29 10:20:00

Command Options

FlagDescriptionDefault
--keyKey name from keyring-
--limitNumber of transactions10
--output, -oOutput format (table/json)table
--nodeRPC endpoint overrideconfig

Limit Results

# Get last 5 transactions
xyz tx history --key mykey --limit 5

# Get last 50 transactions
xyz tx history --key mykey --limit 50

JSON Output

For scripting:
xyz tx history --key mykey --output json
{
  "transactions": [
    {
      "hash": "ABC123DEF456789...",
      "height": 12345,
      "type": "/cosmos.bank.v1beta1.MsgSend",
      "timestamp": "2024-01-29T10:30:00Z"
    },
    {
      "hash": "DEF456789ABC123...",
      "height": 12340,
      "type": "/cosmwasm.wasm.v1.MsgExecuteContract",
      "timestamp": "2024-01-29T10:25:00Z"
    }
  ]
}

Transaction Types

Common transaction types you’ll see:
TypeDescription
/cosmos.bank.v1beta1.MsgSendNative token transfer
/cosmos.staking.v1beta1.MsgDelegateDelegation to validator
/cosmos.staking.v1beta1.MsgUndelegateUndelegation from validator
/cosmwasm.wasm.v1.MsgStoreCodeUpload contract code
/cosmwasm.wasm.v1.MsgInstantiateContractCreate contract instance
/cosmwasm.wasm.v1.MsgExecuteContractExecute contract method
/cosmos.gov.v1beta1.MsgVoteGovernance vote

View Transaction Details

For detailed transaction information, use xyzd:
xyzd query tx <hash> --node tcp://localhost:26657
Or via REST API:
curl "http://localhost:1317/cosmos/tx/v1beta1/txs/<hash>"

Examples

Monitor Activity

# Watch for new transactions
watch -n 10 "xyz tx history --key alice --limit 3"

Export to CSV

# Get JSON and convert
xyz tx history --key alice --limit 100 --output json | \
  jq -r '.transactions[] | [.hash, .height, .type, .timestamp] | @csv' > txs.csv

Filter by Type

# Get only wasm transactions
xyz tx history --key alice --limit 50 --output json | \
  jq '.transactions[] | select(.type | contains("wasm"))'

Count Transactions

# Total transactions (up to limit)
xyz tx history --key alice --limit 100 --output json | \
  jq '.transactions | length'

Understanding Transaction Flow

┌─────────────┐      ┌─────────────┐      ┌─────────────┐
│   Create    │─────▶│   Sign      │─────▶│  Broadcast  │
│     Tx      │      │ (keyring)   │      │  (node)     │
└─────────────┘      └─────────────┘      └─────────────┘


┌─────────────┐      ┌─────────────┐      ┌─────────────┐
│   Query     │◀─────│  Finalized  │◀─────│  Mempool    │
│  (history)  │      │  (block)    │      │  (pending)  │
└─────────────┘      └─────────────┘      └─────────────┘

Transaction Status

Transactions go through these states:
StateDescription
PendingIn mempool, not yet in block
IncludedIn a block, but not finalized
FinalizedBlock confirmed (instant on XYZ Chain)
FailedExecution error (still recorded)
Failed transactions still appear in history with error codes.

Troubleshooting

  • Account may have no transaction history
  • Check address/key is correct
  • Increase limit: --limit 50
  • Node may be syncing
  • Wait a few blocks
  • Check node status: curl http://localhost:26657/status
# Check node is running
xyz localnet status

# Or check RPC endpoint
xyz config get node