Ethereum - Substrate account Mapping
EVM pallet enables the Ethereum EVM capabilities on a native Substrate chain. To make use of EVM similar to any EVM-based blockchain, one should understand how an Ethereum account is mapped relative to the Substrate chain.
Just select the input address format from the dropdown and enter the selected input format address in the input field and click on go. For example:
- Select the input address format to H160(ethereum)
- Enter your Ethereum address and click on go
- You will get your equivalent SS58(substrate) address
- In my case H160, SS58, Public Key and SNOW address were:
H160 address: 0x7c0f5F59A22B657C8D9E21b44D2Dc0118fD2BE7BSS58 address: 5DLri6vcHLAGAs3kQFoE8wP9cG4gHfcqmNrFVZJT2tNMQREXPublic Key: 0x388df59fae952b4e08b8a7b13a5dba9df0151e7ccdd8f897d2fe1e2413c71278SNOW address: nhyYBGP1JvqpB7v8wpwFGWVu1HKJe965TPMw3A8m54j6ih9wL
Every Ethereum address(20-byte) on the EVM is mapped with a unique public key(32-byte) on the Substrate chain, which acts as a proxy to maintain balance for the Ethereum address. This unique public key can be encoded to SNOW address format, which is generated deterministically from the Ethereum address on funding.
The deterministically generated ss58 address is generated by the following steps:
- Consider a 20-byte Ethereum address:
- Add bytes of
evm:as prefix and concat it with the 20-byte Ethereum address bytes.
blake2bHash on the concatenated bytes. This hash is the
public keyassociated with the H160 address.
- Convert the hashed Hex to
SNOW address formatbase address to get the Mapping Substrate account.
H160 address is simply the first 20 bytes of the Substrate public key. This mapping is direct and deterministic which simplifies the address translation.
For Example The SS58 address nhyMVM8op8o7ujq7Mvs6ojUV3cckpwfpsMd4HC47Awbmkjv5X has 32 byte public key 0x306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc20. This account’s equivalent Ethereum address will be 0x306721211d5404bd9da88e0204360a1a9ab8b87c.
Whenever the base Substrate account is funded with some units. A new account is created automatically (if it doesn't exist) & funds will be transferred from the source account to the receiver account.
During any transaction on the EVM, the funds are used by default from the mapped-Substrate address, the EVM always translates the 20-byte Ethereum address to the deterministically generated SS58 address.