Convert ERC-20 tokens to native coins

First, start a localnet

Create a fungible token mapping from an ERC-20 contract

First, deploy an ERC-20 contract. Then, run the following command:

CONTRACT_ADDRESS=0x76e03400dC49dD3Dbede29f5e11b0e7bc215F202

nibid tx evm create-funtoken-from-erc20 \
$CONTRACT_ADDRESS \
--from validator \
--gas auto \
--gas-adjustment 1.5 \
--gas-prices 0.025unibi \
--yes | tx

There should be a EventFunTokenCreated event that displays the new bank coin denom.

Output
{
  "type": "eth.evm.v1.EventFunTokenCreated",
  "attributes": [
    {
      "key": "bank_denom",
      "value": "\"erc20/0x76e03400dC49dD3Dbede29f5e11b0e7bc215F202\"",
      "index": true
    },
    {
      "key": "creator",
      "value": "\"nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl\"",
      "index": true
    },
    {
      "key": "erc20_contract_address",
      "value": "\"0x76e03400dC49dD3Dbede29f5e11b0e7bc215F202\"",
      "index": true
    },
    {
      "key": "is_made_from_coin",
      "value": "false",
      "index": true
    }
  ]
}

Send ERC-20 tokens to bank

Requires calling the FunToken precompile, which can be done with ethers.js.

Last updated

Was this helpful?