How do I get the transactionId from a raw transaction from v2 block explorer

Hi there, I’m having a really hard time trying to figure out how we get the transactionId/transactionHash for a given transaction when querying the block explorer like so

curl https://testnet-api.algonode.cloud/v2/blocks/37782706 | jq

it returns something like this.

  "block": {
    "gen": "testnet-v1.0",
    "gh": "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=",
    "txns": [
      {
        "dt": {
          "lg": [
            "j��>9�w�+\u0011n3/(����u/y���ċFd�w�\u0002\u0000\u0000\u0000\u0011\u000bR\u0002�",
            "j��>9�w�+\u0011n3/(����u/y���ċFd�w�\u0002\u0000\u0000\u0000\u0011\u000bR\u0002�",
            "j��>9�w�+\u0011n3/(����u/y���ċFd�w�\u0002\u0000\u0000\u0000\u0011\u000bQ�?",
            "j��>9�w�+\u0011n3/(����u/y���ċFd�w�\u0002\u0000\u0000\u0000\u0011\u000bQ�?"
          ]
        },
        "hgi": true,
        "lsig": {
          "l": "CCAHAAECSkhNbyYBADEgMgMSRDEJMgMSRDEVMgMSRDEQgQYSRDEBIhJEMQUoEkQiOBAjEkSAIH/pQ5o69ZxO5FyuKGPs0PJsFHKe6X2m7JBO5QgN0zcgNQA0ADUDIjgANAMSRDYaAoAHZGVwb3NpdBJAABs2GgE1ATYaAjUCMRkiEkQ0ATYaAzQCiAD+I0MxGSISMRkjEhFEI0OKAgAoRwQiKEmL/1cASIwHiweMAYsBFRZXBgCLAVCMAYv/i/8hBFmL/yVZUowCi/+L/yVZi/8hBVlSjAaL/4v/IQZZSwEVUowDi/+L/yEFWYv/IQZZUowEi/+BTFWMBYsDVwIAiwZXAgBQjACLABUWVwYAiwBQjACACChDMy5JTykwiwFXAgBQiwJXAgBQiwZXAgBeARJEiwUiEkAAQ4sFIxJAAAEAiwBXAgACiwRXAgBXQAEXgRsJiwRXAgBXACCLBFcCAFcgIAcANQY1BYv+VwwUNAU0BlACVwwUEkRCAA6LAFcCAIsEVwIAi/6ERImKAwAoSSIoRwciRwIoSSKL/owFi/2MAIsAFYEgEkQiNQQ0BIsFIlmMDIsMDEEAiosFiwUkNAQLJAhZJAg0BCMIiwUiWYwNiw0SQABniwUkNAQLJAgkCFkkCFKMB4sHV08gjAGLAIsBEkSLAIsHiP6giweLByEEWYsHJVlSjAiLCFcCAIwJiwlXASCMAIsJIlWMAosCgQMSRIsJgSlbjAuLCyISiwsxAw8RRDQEIwg1BEL/bosFFUL/oIv/V08gjAGLAIsBEkSLAYv/iP5Di/9XAEiMCosKVwAgjA6LDov9EkSLClcgIIwPiwqBQFuMEIsPMQYSixAxBA8QixAiEhFEiQ=="
        },
        "txn": {
          "apaa": [
            "BcI4lg==",
            "auzBPjmud7orEW4zLyi38b2gdS95t7yExItGZMR3iwI=",
            "auzBPjmud7orEW4zLyi38b2gdS95t7yExItGZMR3iwIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEAxgABpGrswT45rne6KxFuMy8ot/G9oHUvebe8hMSLRmTEd4sCAeYAUwZq7ME+Oa53uisRbjMvKLfxvaB1L3m3vITEi0ZkxHeLAgAAAY4RFiEeAAAAAGXntFQEAAABuAfCwsgAAAAAAAAAAAIAAAAAAcTZsAAAAAAAAAAAANxLRU16TGtsUEtUQnE3TUUrT2E1M3Vpc1Jiak12S0xmeHZhQjFMM20zdklURWkwWmt4SGVMQWdBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUdhdXpCUGptdWQ3b3JFVzR6THlpMzhiMmdkUzk1dDd5RXhJdEdaTVIzaXdJQUFBR09FUlloSGdBQUFBQmw1N1JVQkFBQUFiZ0h3c0xJQUFBQUFBQUFBQUFDQUFBQUFBSEUyYkFBQUFBQUFBQUFBQT09AECgpkdaCUiwasc5CWqkHDjClB5X7qDi80skz6k+omct4Cnn8Dt8W7QB3UAOXVbRCk8xA2tp2Td8ZzXAfZe7CLYFAAJNWA==",
            "AAA=",
            "AAAAABaOwYAAAACwO0e4yAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAtHYMAAAAAAAC1XbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE=",
            "AAAAAAAAAAA="
          ],
          "apbx": [
            {
              "n": "auzBPjmud7orEW4zLyi38b2gdS95t7yExItGZMR3iwI="
            },
            {
              "n": "b3JkZXIdBJydYXnfTVrzMIp0+okWROr6xZokK90hnNm0dd+e7w=="
            },
            {
              "n": "aQ=="
            },
            {
              "n": "KeKhZgeOoQwKn8vKTYoiXQ81swn/oHpmQwHePZBctrs="
            }
          ],
          "apfa": [
            486565861
          ],
          "apid": 486568678,
          "fv": 37782704,
          "grp": "hrVKpid2/v/PbfC7hudxej47D79TY62c17oMsNR30AA=",
          "lv": 37783704,
          "snd": "ZHP6PUKRCAEK5DEPO5OBFW4EWFRF5BPDMY5HBJ4GGA7PND6NIWN6U4HERE",
          "type": "appl"
        }
      }
    ]
  }
}

How do I derive the transactionId from this for the given txn? is the only way to construct a Transaction class and use the .txID() method? Surely theres an easier way. (Not using an indexer)

Thanks

1 Like

I use this to compute the txId from the algod data… vote-coin-indexer/src/algo/computeTransactionId.ts at 4bb4c9c83021bd29152a44b9168c9ca561093bd3 · scholtz/vote-coin-indexer · GitHub

2 Likes

@scholtz How are you using this function? Are you doing data conversion before putting the txn into the function?

when I attempt to pass the respective txn like in the example to that function I get
Error: address seems to be malformed
edit: Transaction.from_obj_for_encoding is expecting an EncodedTransaction I don’t think that passing the txn straight from the api works.

maybe this function is intended for usage with algod

2 Likes

this is where its being used: vote-coin-indexer/src/app.ts at 4bb4c9c83021bd29152a44b9168c9ca561093bd3 · scholtz/vote-coin-indexer · GitHub

yes, and you are using algod as well