I am creating an application and signing an extrinsic with a keypair using the keyring. I was wondering if I can receive the transaction hash somehow after it has been signed

  • can you provide source to your application? What libs are you using to sign? what keyring?
    – Nuke
    May 2, 2022 at 21:40
  • Please also checkout substrate.stackexchange.com/help/how-to-ask - better formed questions here will get you better answers :) Welcome to the community!
    – Nuke
    May 2, 2022 at 21:42
  • Basically I'm looking for something similar to ethers.providers.TransactionResponse from the ethers project but for polkadot. Something That I can pass a signed transaction or even a signature to and retrieve a transaction hash May 2, 2022 at 21:55
  • I am using the polkadot SignPayload function and was wondering if I can retrieve the transaction hash from it May 3, 2022 at 1:46
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    May 4, 2022 at 14:47

1 Answer 1

import { blake2AsHex } from '@polkadot/util-crypto';

 * Derive the tx hash of a signed transaction offline.
 * @param signedTx - The hex encoding of a signed transaction.
export function getTxHash(signedTx: string): string {
    return blake2AsHex(signedTx, 256);
  • This doesn't seem to work as expected. See here: westend.subscan.io/extrinsic/10696943-2 I expected to get the exstrinsic hash: 0xb11b3c5e7ef8efb518de8f0b6ca0107d06a47c6da949cd39ef40a76753c87ff8 But I ended up getting this extrinsic hash: 0x0fb3c429f27ffe991796ce594525eeac301a16a2f0ccd4f4caec2979332feadd From the following signature: 0x85af7c6a21502dbdbd123596d804ad5eba1343d9c61128c7f96bb719887081ba5953519d68e8a9a2ff853c3d656a1406f2e814b456fcd983fa1c853fa62f3a03 Any ideas? May 4, 2022 at 15:50
  • You need the entire extrinsic, not just the signature. You can see how Sidecar does it: github.com/paritytech/substrate-api-sidecar/blob/992b458/src/… May 4, 2022 at 18:39

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.