4

PolkadotJS explorer provides a hash value for every extrinsic (see marked screenshot) but the extrinsics list from block data (block.extrinsics) does not explicitly provide one. How is this value obtained?

// A snippet of block data object with extrinsics list without hash values
{
    "header": {
        "parentHash": "0xf1b7dd959ccf1fd4d3fbb4899d80a2b2a39532237583e513625c74184b455deb",
        "number": "9,239,202",
        "stateRoot": "0x1c46f814b57b5ce14048f45158ae9e639d23af331542049337d0c137acc17ba8",
        "extrinsicsRoot": "0x828199393cd2f976bf42ed44f026005a5605f07e4d18781ab48a00d67f22b34f",
        "digest": {
            "logs": [
                ...
            ]
        }
    },
    "extrinsics": [
        {
            "isSigned": false,
            "method": {
                "args": {
                    "now": "1,646,142,240,003"
                },
                "method": "set",
                "section": "timestamp"
            }
        },
        {
            "isSigned": false,
            "method": {
                "args": {
                    "data": {
                        "bitfields": [
                            {
                                "payload": "0b00100001_00000000_00000000_00000000_00000000",
                                "validatorIndex": "0",
                                "signature": "0xf4cea4e34cf0ad5a15ec171659b2548ae56317eca6aa53d0d2c7a8cb3cb2fd08666673c2991182101c7474452f28b027f8d41ee07e41244987261d988482e986"
                            },
                            ...
                        ],
                      ...
                    }
                },
                "method": "enter",
                "section": "paraInherent"
            }
        },
        {
            "isSigned": true,
            "method": {
                "args": {
                    "dest": {
                        "Id": "1urK7po3hNyt9FWSbUrMspUGkWw69ChF1KDkcs4Do3F3HoV"
                    },
                    "value": "46,620,000,000,000"
                },
                "method": "transferKeepAlive",
                "section": "balances"
            },
            "era": {
                "MortalEra": {
                    "period": "512",
                    "phase": "158"
                }
            },
            "nonce": "81,499",
            "signature": "0x675bc56707feb5dc7a0cc90f40ccb21d8dd29733dea0e200c21b7eebabe952c903f31f0b8d57beaf17f578e1c58203de3981d2db4d9a9f1aaf6501ef6b771106",
            "signer": {
                "Id": "16hp43x8DUZtU8L3cJy9Z8JMwTzuu8ZZRWqDZnpMhp464oEd"
            },
            "tip": "0"
        },
        {
            "isSigned": true,
            "method": {
                "args": {
                    "dest": {
                        "Id": "12xtAYsRUrmbniiWQqJtECiBQrMn8AypQcXhnQAc6RB6XkLW"
                    },
                    "value": "86,098,832,999,986"
                },
                "method": "transfer",
                "section": "balances"
            },
            "era": {
                "MortalEra": {
                    "period": "64",
                    "phase": "30"
                }
            },
            "nonce": "0",
            "signature": "0xaaa69f52ad20cb51aeedd3ad341fdcba34a19ea0f2fbafea643cf182b01b2e115a246df31ac07f940bf2f1bc5584325faaba178759369058273a313b37ce358e",
            "signer": {
                "Id": "13fkvT1NZnWVu762tMCP5Se8wXZPzuawJgW2qJYFTidB7rbq"
            },
            "tip": "0"
        },
        {
            "isSigned": true,
            "method": {
                "args": {
                    "dest": {
                        "Id": "12xtAYsRUrmbniiWQqJtECiBQrMn8AypQcXhnQAc6RB6XkLW"
                    },
                    "value": "57,471,153,886"
                },
                "method": "transfer",
                "section": "balances"
            },
            "era": {
                "MortalEra": {
                    "period": "64",
                    "phase": "30"
                }
            },
            "nonce": "0",
            "signature": "0x1c736068e09d6005a099089f905d1cdc22547109b957c71cbce5cab3dd01b06a7263ec2be84eb1b74742c5e19c907ab3e2deac528d52104d27e0317bb42edc8a",
            "signer": {
                "Id": "14dGnV6asvvAXjE8fffv5d3C3BeGCRUDuidXfK6LDwTPiqAt"
            },
            "tip": "0"
        }
    ]
}

Extrinsic hash on polkadot explorer

1 Answer 1

4

With polkadot{.js} API you should be able to get the extrinsic hash:

// the hash for each extrinsic in the block
signedBlock.block.extrinsics.forEach((ex, index) => {
  console.log(index, ex.hash.toHex());
});

Source: https://polkadot.js.org/docs/api/cookbook/blocks#how-do-i-retrieve-the-headerextrinsic-hash-from-blocks

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.