4

I get the following error while trying to fetch block #1375921 on Kusama chain:

RPC-CORE: getBlock(hash?: BlockHash): SignedBlock:: createType(SignedBlock):: Struct: 
failed on block: {"header":"Header","extrinsics":"Vec<Extrinsic>"}:: Struct: failed on 
extrinsics: Vec<Extrinsic>:: createType(ExtrinsicV4):: createType(Call):: Call: failed 
decoding balances.transfer:: Struct: failed on args: 
{"dest":"LookupSource","value":"Compact<Balance>"}:: decodeU8a: failed at 
0x86b7409a11700afb027924cb40fa4388… on dest: {"_enum": {"Id":"AccountId","Index":"Compact<AccountIndex>","Raw":"Bytes","Address32":"H256","Address20":"H160"}}:: Unable to create Enum via index 134, in Id, Index, Raw, Address32, Address20

I'm on @polkadot/api v7.12.1 . How may I rectify this error?

2 Answers 2

4

There was indeed an issue in the 7.11.x series for historical blocks, however 7.12.1 included the fix. However the answer above to check against (a) the apps UI (which generally is very fresh, even betas) and (b) check later versions is generally good.

However in this case, there is nothing that needs an upgrade. This code works locally -

import { ApiPromise, WsProvider, packageInfo } from '@polkadot/api';

async function main () {
  const api = await ApiPromise.create({ provider: new WsProvider('wss://kusama-rpc.polkadot.io') });
  const blockHash = await api.rpc.chain.getBlockHash(1375921);
  const block = await api.rpc.chain.getBlock(blockHash);

  console.log(`@polkadot/api ${packageInfo.version}`);
  console.log(JSON.stringify(block.toHuman()));
}

main().then(() => process.exit());

With the following dependencies -

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "node ./test.mjs"
  },
  "dependencies": {
    "@polkadot/api": "7.12.1"
  }
}

It outputs the following (version included for sanity) -

$ node ./test.mjs
@polkadot/api 7.12.1
{"block":{"header":{"parentHash":"0x34d769953a4f0b33d13f509129d93591c02e00eb678d6f935748cc2bf5d8f06b","number":"1,375,921","stateRoot":"0x67d8d1f6274a0895ac2c38f3883a721b73cd14769b52a9edf83236b70ed6b1b0","extrinsicsRoot":"0xb2d7e1384ce2f2ee72dd0c28338bcb73a3f26c2e5c33bb6dcb81f967a7813688","digest":{"logs":[{"PreRuntime":["BABE","0x010c00000078b6bb0f000000007ad0448d3d622242c9347fa9ef38d8754e60fec552f18b28424ad9b54547394902f7748a0e3a05a36848171d13c5858d213329fa2ef588d751b3f562f1beb1099c33331dc63947411f4cd1363a8db610e0745b7489fc6e14a77cb8b96726250f"]},{"Seal":["BABE","0x66b2ae937711e397e17f73189831f860d784d9ed499848b86441511e20f181512bf37f1c44c53b4ce9614784833aabacc2fbaf55d5aa668c7c1a0cea5d7e9e87"]}]}},"extrinsics":[{"isSigned":false,"method":{"args":{"now":"1,583,761,104,000"},"method":"set","section":"timestamp"}},{"isSigned":false,"method":{"args":{"hint":"1,375,918"},"method":"finalHint","section":"finalityTracker"}},{"isSigned":false,"method":{"args":{"heads":[]},"method":"setHeads","section":"parachains"}},{"isSigned":true,"method":{"args":{"dest":"FcxNWVy5RESDsErjwyZmPCW6Z8Y3fbfLzmou34YZTrbcraL","value":"2.0000 KSM"},"method":"transfer","section":"balances"},"era":{"MortalEra":{"period":"64","phase":"45"}},"nonce":"0","signature":"0x7a1effc5c8348a0262585d43aceea41171a849c3173b151c132b8fa093c9a4064b4459f978ac277b7cbd5dd047d907cbb6497c1fa9e607dee9c1c79276df778e","signer":"Ead9wbT57JWbVt2SVQMzuuGmegydWa3SadGVypS8DKEZigo","tip":"0"}]},"justifications":null}

It would point to a local issue, no types should be injected for Kusama/Polkadot/etc. The API ships with everything required. This does sound like possibly an Address types that was added, resulting in everything after it being incorrect.

1

Since it works in the latest API on apps, 1375921 decoded, an upgrade to a recent version may be in order.

Seems it could be related to the fixed 4645

1
  • Is it possible to know the version of the api in which the fix was released? I'm using a third-party project which uses v7.12.1 in it's dependency
    – Naveen
    Mar 28, 2022 at 6:48

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.