Prerequisites
Project Setup
First, we need to create a new directory for our project.index.js
file in a src
directory.
Development
For this tutorial, we will assume that we have an ERC20 token address0x5E5f1a92eECA58053E8364630b66763aa6265Ab0
that we want to convert to a Cosmos coin denom, and then convert it back to an ERC20 token address.
First, we initialize the variable for the chain’s LCD endpoint and the ERC20 token address.
src/index.js
ERC20 to Cosmos Denom
To actually do the conversion, we will be using the LCD’s/minievm/evm/v1/denoms/{contractAddress}
endpoint.
src/index.js
Cosmos Denom to ERC20 Address
To convert a Cosmos coin denom back to an ERC20 token address, we will be using the LCD’s/minievm/evm/v1/contracts/by_denom?denom={denom}
endpoint.
src/index.js
src/index.js