Convert a Substrate address into an EVM address
If you’re using the EVM pallet of a Substrate chain, you might need to convert a substrate address into its EVM version, so that you can send transactions via the EVM.
We just need to quickly set up the environment, it’s very simple just follow and along and you will have the EVM version of your Substrate address at the end of this.
Time: less than 5 minutes.
- npm init
- Name the file “evm-convert”
- Copy this code and add into a file called evm-address.js
https://github.com/paritytech/frontier/blob/master/template/utils/evm-address.js
4. Copy this code and add into a file called index.js
https://github.com/paritytech/frontier/blob/master/template/utils/index.js
5. Copy this code and add into a file called package.json
https://github.com/paritytech/frontier/blob/master/template/utils/package.json
6. npm install
Then run this command in the command line inside the directory:
node index.js — evm-address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
You should get an EVM address as the result:
Repeat, and replace the substrate address for your chosen address.
Enjoy!
Ramsey
Decentration Labs