Deposit and Withdraw Token
This tutorial explains how to deposit and withdraw funds on the InfraEVM parachain.
Before you begin
Before you begin, make sure to do the following:
Converting Addresses
InfraEVM Parachain uses two address systems:
SS58 address
H160 address
SS58 addresses are used in the Substrate layer, while H160 addresses are used in the EVM layer.
SS58 Address to H160 Address
Converting an SS58 address to an H160 address is done as shown in the image above.
It involves decoding the SS58 address and using the first 20 bytes of the resulting 32-byte buffer as the H160 address.
A JavaScript file that implements this conversion is included in the repository.
Here's how to convert SS58 addresses to H160 addresses:
Open your computer's terminal shell.
Clone InfraEVM Parachain repository by running the following command:
This command clones the
master
branch.Navigate to the root of the node template directory with the following command:
Create a new branch for your work:
Replace
yyyy-mm-dd
with your desired identification information. We recommend using a numeric year-month-day format. For example:Execute the following command to perform the address conversion:
H160 Address to SS58 Address
Converting an H160 address to an SS58 address is done as shown in the image above.
It involves combining a buffer composed of the string "evm:"
and a buffer composed of the H160 address, then obtaining the hash value using the blake2
hash function and encoding the resulting hash value in SS58 format to obtain the SS58 address.
A JavaScript file that implements this conversion is included in the repository.
Here's how to convert H160 addresses to SS58 addresses:
Open your computer's terminal shell.
Clone InfraEVM Parachain repository by running the following command:
This command clones the
master
branch.Navigate to the root of the node template directory with the following command:
Create a new branch for your work:
Replace
yyyy-mm-dd
with your desired identification information. We recommend using a numeric year-month-day format. For example:Execute the following command to perform the address conversion:
Moving Assets from Substrate to EVM
Use the method explained above to obtain the SS58 address mapped to the H160 address to be used in EVM.
Transfer assets to the obtained SS58 address.
By default, InfraEVM Parachain is integrated to use asset 99 as the native token of the EVM.
Verify that it reflects in EVM wallets like MetaMask.
Moving Assets from EVM to Substrate
Use the method explained above to obtain the EVM address mapped to the SS58 address to be used in Substrate.
Transfer assets to the obtained EVM address.
Access the InfraBlockchain Explorer and follow the steps below.
Navigate to
Developers
-Extrinsics
-evm
palette and select thewithdraw
extrinsic.Configure it as shown below and dispatch the extrinsic:
The SS58 account used for address conversion in step 1 should execute the extrinsic.
Check the events to confirm that the assets were successfully deposited.
Next Steps
Last updated