Junø
WebDiscordGithubTwitter
  • Juno
    • Intro
    • Home of CosmWasm
    • Contributors - Core Software
    • Brand Identity
    • Security Disclosures
    • Economic Overview
      • Disclaimer
      • Native Asset (JUNO)
      • Incentive structure
      • Supply API - Data
  • Developer Guides
    • CosmWasm Contracts
      • Compile a Contract
      • Deploy a Contract
      • Guide: How to Upload a Smart Contract on the Juno Chain
      • Use Cw-orchestrator to speed-up your development
      • Query A Contract
      • Send Tokens to a Contract
    • Miscellaneous
      • Conversions
      • Multi Message Transaction
      • Get & Decode Transactions
      • Get Token Prices
      • Get Account Transactions
      • IBC Transfer
      • State Export / Airdrop
    • Juno Modules
      • FeeShare
      • TokenFactory
    • API Endpoints
      • Cosmos
        • Tx
          • V1beta1
            • Simulate
            • Txs
              • Block
        • Params
          • V1beta1
            • Params
        • Bank
          • V1beta1
            • Balances
              • By denom
            • Denoms metadata
            • Params
            • Spendable balances
            • Supply
        • Upgrade
          • V1beta1
            • Applied plan
            • Current plan
            • Module versions
            • Upgraded consensus state
        • Auth
          • V1beta1
            • Accounts
            • Module accounts
            • Params
        • Staking
          • V1beta1
            • Delegations
            • Historical info
            • Params
            • Pool
            • Validators
              • Delegations
                • Unbonding delegation
              • Unbonding delegations
            • Delegators
              • Redelegations
              • Unbonding delegations
              • Validators
        • Evidence
          • V1beta1
            • Evidence
        • Mint
          • V1beta1
            • Annual provisions
            • Inflation
            • Params
        • Feegrant
          • V1beta1
            • Allowance
            • Allowances
            • Issued
        • Gov
          • V1beta1
            • Params
            • Proposals
              • Deposits
              • Tally
              • Votes
        • Distribution
          • V1beta1
            • Community pool
            • Params
            • Delegators
              • Rewards
              • Validators
              • Withdraw address
            • Validators
              • Commission
              • Outstanding rewards
              • Slashes
        • Slashing
          • V1beta1
            • Params
            • Signing infos
        • Authz
          • V1beta1
            • Grants
              • Grantee
              • Granter
        • Base
          • Tendermint
            • V1beta1
              • Blocks
                • Latest
              • Node info
              • Syncing
              • Validatorsets
                • Latest
          • Node
            • V1beta1
              • Config
      • Cosmwasm
        • Wasm
          • V1
            • Code
              • Contracts
            • Contract
              • History
              • Raw
              • Smart
              • State
            • Codes
              • Params
              • Pinned
            • Contracts
              • Creator
      • Juno
        • Feeshare
          • V1
            • Fee shares
            • Params
        • Tokenfactory
          • V1beta1
            • Denoms from creator
            • Params
            • Denoms
              • Authority metadata
      • Ibc
        • Apps
          • Router
            • V1
              • Params
      • API Specification
    • Local Interchain
      • Local Interchain Rust Example
    • Junod Local Dev Setup
    • Integrate Leap wallet
    • SubQuery Indexer
  • Governance
    • Before submitting a proposal
    • Submitting a Proposal (CLI)
      • Formatting Proposal Markdown
  • Command-Line Interface (CLI)
    • Introduction
    • Useful CLI Commands
    • Module Reference
      • bank
      • distribution
      • gov
      • keys
      • params
      • slashing
      • staking
      • status
      • tendermint
      • upgrade
      • wasm
  • Nodes & Validators
    • Junod Installation and setup
    • Setting up Cosmovisor
    • Mainnet Setup and Tooling
    • Joining Mainnet
      • Sync from Snapshot
      • Sync with state-sync
      • Mainnet Upgrades
    • Joining Testnet
    • Relaying
    • Juno Delegations Program
Powered by GitBook
On this page
  • Get Transactions
  • Get with RPC:
  • Get with REST API:
  • Get with CLI:
  • Decode: Command Line
  • Decode with Python (junod)
  • Decode with Python (protobuf)

Was this helpful?

  1. Developer Guides
  2. Miscellaneous

Get & Decode Transactions

PreviousMulti Message TransactionNextGet Token Prices

Last updated 2 years ago

Was this helpful?

Get Transactions

You can get a blocks transactions both via the RPC and REST API. You can find other public endpoints on the website

Get with RPC:

URL: Transaction Array: result.block.data.txs[]

Get with REST API:

URL: Transaction Array: block.data.txs[]

Get with CLI:

# apt install jq     |  pacman -S jq
junod q block | jq .block.data.txs

Decode: Command Line

You can decode transaction data using the junod command:

junod tx decode <base64-amino-byte-string> --output=json

For example

junod tx decode CoMECvwBCiQvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QS0wEKK2p1bm8xaHRzOGdnMHdudXhxazl4ZXJ1a3djNHB4ZG1ncmdoZG5qdjhnZGcSP2p1bm8xZzVqOXZkNzZjcXQ3ZnNxMjJuZTdqcWZrejR2OXB0a3ZoNGprbnN2d2NocGo3NTNhdHdmczk0MmEyNRpOeyJzd2FwIjp7ImlucHV0X3Rva2VuIjoiVG9rZW4yIiwiaW5wdXRfYW1vdW50IjoiNDUyOTAwMDAwMCIsIm1pbl9vdXRwdXQiOiIwIn19KhMKBXVqdW5vEgo0NTI5MDAwMDAwCoECCiQvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QS2AEKK2p1bm8xaHRzOGdnMHdudXhxazl4ZXJ1a3djNHB4ZG1ncmdoZG5qdjhnZGcSP2p1bm8xZThuNmNoN21za3M0ODdlY3pueWVhZ216ZDVtbDJwcTl0Z2VkcXQydTYzdnJhMHEwcjltcXJqeTZ5cxpUeyJzd2FwIjp7ImlucHV0X3Rva2VuIjoiVG9rZW4xIiwiaW5wdXRfYW1vdW50IjoiNDUyOTAwMDAwMCIsIm1pbl9vdXRwdXQiOiI2MDAwMDAwIn19KhIKBXVqdW5vEgk5NjkwMDAwMDASZgpQCkYKHy9jb3Ntb3MuY3J5cHRvLnNlY3AyNTZrMS5QdWJLZXkSIwohA2IKqvhI5iJwjhzNfy90VKT/UKcn7hQtmJD2WtPxiIY5EgQKAggBGEsSEgoMCgV1anVubxIDNjAwEMOaDBpAh+kKHSm07sTOYe8K/m7GhSGgmciMjGPD7eTLtLHX2x1Rp5e0m+cHK2rFB9f9ZNRITrf0L7E/emsOKjdFkUFbnA== --output json

returns

{
   "body":{
      "messages":[
         {
            "@type":"/cosmwasm.wasm.v1.MsgExecuteContract",
            "sender":"juno1hts8gg0wnuxqk9xerukwc4pxdmgrghdnjv8gdg",
            "contract":"juno1g5j9vd76cqt7fsq22ne7jqfkz4v9ptkvh4jknsvwchpj753atwfs942a25",
            "msg":{
               "swap":{
                  "input_token":"Token2",
                  "input_amount":"4529000000",
                  "min_output":"0"
               }
            },
            "funds":[
               {
                  "denom":"ujuno",
                  "amount":"4529000000"
               }
            ]
         },
         {
            "@type":"/cosmwasm.wasm.v1.MsgExecuteContract",
            "sender":"juno1hts8gg0wnuxqk9xerukwc4pxdmgrghdnjv8gdg",
            "contract":"juno1e8n6ch7msks487ecznyeagmzd5ml2pq9tgedqt2u63vra0q0r9mqrjy6ys",
            "msg":{
               "swap":{
                  "input_token":"Token1",
                  "input_amount":"4529000000",
                  "min_output":"6000000"
               }
            },
            "funds":[
               {
                  "denom":"ujuno",
                  "amount":"969000000"
               }
            ]
         }
      ],
      "memo":"",
      "timeout_height":"0",
      "extension_options":[
         
      ],
      "non_critical_extension_options":[
         
      ]
   },
   "auth_info":{
      "signer_infos":[
         {
            "public_key":{
               "@type":"/cosmos.crypto.secp256k1.PubKey",
               "key":"A2IKqvhI5iJwjhzNfy90VKT/UKcn7hQtmJD2WtPxiIY5"
            },
            "mode_info":{
               "single":{
                  "mode":"SIGN_MODE_DIRECT"
               }
            },
            "sequence":"75"
         }
      ],
      "fee":{
         "amount":[
            {
               "denom":"ujuno",
               "amount":"600"
            }
         ],
         "gas_limit":"200003",
         "payer":"",
         "granter":""
      }
   },
   "signatures":[
      "h+kKHSm07sTOYe8K/m7GhSGgmciMjGPD7eTLtLHX2x1Rp5e0m+cHK2rFB9f9ZNRITrf0L7E/emsOKjdFkUFbnA=="
   ]
}

Decode with Python (junod)

# python3 -m pip install httpx
import httpx, json, os

RPC_URL = "https://rpc.juno.strange.love:443"
height = 7_000_000

client = httpx.Client()
tx_data: dict[int, dict] = {}

def run_cmd(cmd) -> str:
    return os.popen(cmd).read()


def get_block_transactions(height: int) -> list[str]:
    block = client.get(f"{RPC_URL}/block?height={height}").json()
    block_txs = block["result"]["block"]["data"]["txs"]
    return block_txs


def main():
    version = run_cmd("junod version")
    if len(version) == 0:
        print("Junod not installed. Please install junod and try again.")
        exit(1)

    txs = get_block_transactions(height=height)

    for tx in txs:
        txs_json = json.loads(run_cmd(f"junod tx decode {tx} --output json"))
        tx_data[height] = txs_json.get("body", {}).get("messages", [])

    # Do something with that tx data here
    print(tx_data)

if __name__ == "__main__":
    main()

Decode with Python (protobuf)

If you have experience with protobuf, you can use cosmospy to decode transaction data and decode is from base64 strings

# python -m pip install cosmospy-protobuf
import base64
import cosmospy_protobuf.cosmos.tx.v1beta1.tx_pb2 as tx_pb2

tx = "CpMBCpABChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEnAKLWNvc21vczEweGw5cXV1Z2N2amhsMGdsamplaG1oeHhhN3cwaDM5ZTJ2aGFndhItY29zbW9zMThsemp0NWpwcjdtd3U0dHlkbGNmZ2N1dHI2Z25ycGsweWo4ZnNjGhAKBXVhdG9tEgcxMDAwMDAwEmcKUApGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQM+g5XXnqLLelLxz8CTy+vG5aO7SohNKS78OtL9ysdcEhIECgIIARgCEhMKDQoFdWF0b20SBDIyNzUQ+MYFGkBbTDHP0mn8d2hxQnNUE/SeudBrXMgjyRO5Bv12D4iWgk4cPsczc6EaDQD3v7cqqD22HL8ZZXVMF3GKi1SNAGNT"
decode64 = base64.b64decode(tx)
tx = tx_pb2.Tx()
tx.ParseFromString(decode64)

print(tx)
# print(tx.body.messages)

Using junod and python, we can save this JSON data for later using the following example. This excerpt was taken from the

https://cosmos.directory/juno/nodes
https://rpc.juno.strange.love/block
https://api.juno.strange.love/cosmos/base/tendermint/v1beta1/blocks/latest
juno-analysis repo