TL: DR
Sets a dummy code for ERC20 Native, AuthorMapping, Randomness and XcmUtils precompiles so smart contracts can more easily interact with them.
Summary
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
Proposal #36 with the following hash: 0x3f994bcbc10217f5eebf472b9a872767308106c187095618615635549b32be0d
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:
0x00051011011da53b775b270400e7e61ed5cbc5a146ea70f53d5a3306ce02aaf97049cf181af5447e3dbad3033904cd6f50fbce673e0000000000000000000000000000000000000802181460006000fd11011da53b775b270400e7e61ed5cbc5a146ea70f53d5a3306ce02aaf97049cf181abbb77f5fe3a60fd004a7063f17f63dda0000000000000000000000000000000000000807181460006000fd11011da53b775b270400e7e61ed5cbc5a146ea70f53d5a3306ce02aaf97049cf181ac1c062eb3ecc887abc7fd90c52bc68420000000000000000000000000000000000000809181460006000fd11011da53b775b270400e7e61ed5cbc5a146ea70f53d5a3306ce02aaf97049cf181a5ae0b760b393d12e71ff11e979ba8fdc000000000000000000000000000000000000080c181460006000fd
You can find the code use to calculate the SCALE encoded call data here.