1

I'm launching an author_submitAndWatchExtrinsic and would like to get the Tx Hash as well:

{"jsonrpc":"2.0","id":9,"method":"author_submitAndWatchExtrinsic","params":["0x21038400D43593C715FDD31C61141ABD04A99FD6822C8558854CCDE39A5684E7A56DA27D017C79B5352D63C74387DB33D7FBFAEC6B5BB66551A190E890664B779C72AAE307058319F6A24CAC69BB3811BCE04466E692626DCFA40B0DC61A86C92AF8AD0383E5002D1100460600C21E50C0CCF079AC73C784CC5136F3424B562897AFFDBCC102A36CA094DDE3120003003881EB02B007000107009CA6920CAC1BA63D86363617270650000000000000000000000000000000000000000000000000000014616161616100"]}

{"jsonrpc":"2.0","result":"esTxSZq5YkhTEBOD","id":9}

{"jsonrpc":"2.0","method":"author_extrinsicUpdate","params":{"subscription":"esTxSZq5YkhTEBOD","result":"ready"}}

{"jsonrpc":"2.0","method":"author_extrinsicUpdate","params":{"subscription":"esTxSZq5YkhTEBOD","result":{"broadcast":["12D3KooWSP9NzUUABoSZnv4uqXmFyPXbMmsnRRYWgYdhwxtBZ6jd","12D3KooWMRAZckcmcTUrVzppAzKaeeyyr2xvqJ7L1Tx5UMDGj5df","12D3KooWDo5QVqvXqWcSWDbiAJXNEGvp5kXmGvMikv75raBFxsdp","12D3KooWDDjUyuMTYGavby1o5uPUdSJfvdDtzjV6CB8pHYy7BBSZ","12D3KooWS3kTgy984oowUbUgJFaQT92Vb9FUuDTJgX2Rmz7Wexut","12D3KooWK6sFZNqpK352n94jnXkoG5d9kgEaEMhBTjm8F79FmqpY","12D3KooWHZDfziaseXEJ6UrCi45bz1veLNBbB7avtEsUhGkn5MZ3","12D3KooWRVMXSpnY4yAXbLhd99wsgvHKosmcFY1HvpsD2AxBDbnh","12D3KooWNfADqVKZFtiTDvR4CYF6pro5KVXeBEKYBHh5ohLAHrqk","12D3KooWJXFqXJbnwfdSqe83epVHHPx8LRs3ZNMkuq6Cnj7kDfpV","12D3KooWQ1RYXWLstTLeNi6iU4ThS8WYo9hhDQyMiDsCci8zREwj"]}}}

{"jsonrpc":"2.0","method":"author_extrinsicUpdate","params":{"subscription":"esTxSZq5YkhTEBOD","result":{"inBlock":"0xa7ddecc6399afee1dd175b273f70f161513e524b50d292c50823e35506591ecc"}}}

{"jsonrpc":"2.0","method":"author_extrinsicUpdate","params":{"subscription":"esTxSZq5YkhTEBOD","result":{"finalized":"0xa7ddecc6399afee1dd175b273f70f161513e524b50d292c50823e35506591ecc"}}}

But from the websocket I can only get this information.

I would like to understand how to identify my Tx in the block, because I have to understand if it was executed successfully or not, it's not enough for me to know if it was included in a finalized block.

Is there no way to recover at least the Tx Hash?

According to documentation https://wiki.polkadot.network/docs/build-protocol-info#unique-identifiers-for-extrinsics

The correct way to uniquely identify an extrinsic on a Substrate-based chain is to use the block ID (height or hash) and the extrinsic's index. Substrate defines a block as a header and an array of extrinsics; therefore, an index in the array at a canonical height will always uniquely identify a transaction. This methodology is reflected in the Substrate codebase itself, for example to reference a previous transaction from the Multisig pallet.

But in this case how to identify the Index of my extrinsic the in finalized block?

1 Answer 1

1

In Substrate-based chains like Polkadot, a transaction's hash only serves as a fingerprint of the information within a transaction, is not unique, and there are times when two transactions with the same hash are both valid. See an example here: Why could we find the same transaction hash in 3 different blocks?.

With the author_submitAndWatchExtrinsic you get the hash of the block when is finalised and with that you can query the block and comparing it with your extrinsic hash you can construct your extrinsic ID: block ID (height or hash) and the extrinsic's index.

You can see a code snippet of how to do it in Polkadot JS and a bit more detailed explanation about extrinsic IDs here: Best practices for generating and monitoring transactions

3
  • author_submitAndWatchExtrinsic doesn't return Hash of Tx, so I'm not able to lookup my TX within the finalized blockhash. (in case I have multiple calls to the smartcontratc in the block).
    – FedeC87p
    Aug 27, 2023 at 18:32
  • you are not getting this {"jsonrpc":"2.0","method":"author_extrinsicUpdate","params":{"subscription":"esTxSZq5YkhTEBOD","result":{"finalized":"0xa7ddecc6399afee1dd175b273f70f161513e524b50d292c50823e35506591ecc"}}}?
    – Alex Bean
    Aug 28, 2023 at 6:24
  • this is the blockhash 0xa7ddecc6399afee1dd175b273f70f161513e524b50d292c50823e35506591ecc ( shibuya.subscan.io/block/… ) inside you can see on subscan that contains contracts (call), but I don't find how to retrieve HASH from this call, it seems strange to me
    – FedeC87p
    Aug 28, 2023 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.