[Referendum: 83] Set Code for AuthorMapping, Randomness and XcmUtils Precompiles

Polkassembly post


Sets a dummy code for AuthorMapping, Randomness and XcmUtils precompiles so smart contracts can more easily interact with them.


Precompiles are system contracts that don’t have any code in it. Therefore, eth_getCode returns 0x or emtpy.

When smart contracts make calls to other contracts like Contract.functionName there is code.length check which fails. Consequently, smart contracts can’t easily call/interact with precompiles.

By setting this dummy code (0x60006000fd, which is a basic revert opcode) smart contracts can now more easily interact with these precompiles.


Proposal #X19 with the following hash: 0x9e4ca11e73b4b33d47ceee3cae51326b5df3ffd91ee58c6c8866496b5e82ee66

Technical details:

The storage key for an address can be calculated using the following code:

const getStorageKey = async (address) => {
  let palletEncoder = new TextEncoder().encode('EVM');
  let palletHash = xxhashAsU8a(palletEncoder, 128);
  let storageEncoder = new TextEncoder().encode('AccountCodes');
  let storageHash = xxhashAsU8a(storageEncoder, 128);
  let assetAddress = new Uint8Array(hexToU8a(address));
  let addressHash = blake2AsU8a(assetAddress, 128);
  let concatKey = new Uint8Array([...palletHash, ...storageHash, ...addressHash, ...assetAddress]);

  return u8aToHex(concatKey);

The SCALE encoded call data is:


You can find the code use to calculate the SCALE encoded call data here.