I created kusama transfer function using polkadot.js/api.
I followed https://polkadot.js.org/docs/api/examples/promise/make-transfer.

I can get extrinsic hash from above. I want to get extrinsic detail to check if transaction is success or not.
According to my check, it is impossible to check extrinsic detail with hash only.
Extrinsic Hash and Block number are both needed.

I also tried callback, but it doesn't show blockhash for me. When I log status, it is just {ready: null}

How can I get block number or block hash from transfer?

1 Answer 1


To get the blockHash where it has been included your transaction, you can send it and then wait until it has been included in the block using a subscription.

const unsub = await api.tx.balances.transfer(BOB, 12345).signAndSend(alice, (result) => {
    console.log(`Current status is ${result.status}`);

    if (result.status.isInBlock) {
      console.log(`Transaction included at blockHash ${result.status.asInBlock}`);
    } else if (result.status.isFinalized) {
      console.log(`Transaction finalized at blockHash ${result.status.asFinalized}`);

Then you can get the block information(number, hash...) and the extrinsics in that block:

const blockHash = result.status.asFinalized;
const signedBlock = await api.rpc.chain.getBlock(blockHash);
const extrinsics = signedBlock.block.extrinsics;
  • Hey. Thank you for your answer. I also tried it but it doesn't work for me. When I log result.status, it is just ready and if condition log does not happen
    – Heindrick
    Commented Nov 11, 2022 at 9:34
  • I have tried it in the Polkadot network and works, make sure you are importing you are creating the Keyring propertly: polkadot.js.org/docs/keyring/start/create and specific for Kusama: polkadot.js.org/docs/keyring/start/ss58
    – Alex Bean
    Commented Nov 11, 2022 at 10:10
  • Yes. Tranasaction is done. This mean, I am doing correctly, just I can't get block hash
    – Heindrick
    Commented Nov 11, 2022 at 10:16
  • Do you close your connection after the transfer? you may have to wait a bit to get the message that is included in a block, and check you have the await
    – Alex Bean
    Commented Nov 11, 2022 at 11:45
  • Yes, I think it is logical. I will try to add setTimeout.
    – Heindrick
    Commented Nov 11, 2022 at 12:11

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.