Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: initial implementation of evm->native bridge #70

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

taokayan
Copy link
Contributor

@taokayan taokayan commented Mar 5, 2025

Resolves #61 & #63

deployment prerequisites:

1- have evm runtime contract (eosio.evm), this contract (eosio.erc2o) deployed
2- an existing ERC-20 token on EVM side, for example, token deployed in 0x4d9dbb271ee2962f8becd3b27e3ebcd384ad3171

3- an existing mirrored token on native side, for example: goldgoldgold, if not, create & issue the mirrored token:

./cleos set code goldgoldgold eosio.token.wasm
./cleos set abi goldgoldgold eosio.token.abi
./cleos push action goldgoldgold create '{"issuer":"goldgoldgold", "maximum_supply":"1000000.0000 GOLD", "can_freeze":0, "can_recall":0, "can_whitelist":0}' -p goldgoldgold@active
./cleos push action goldgoldgold issue '{"to":"goldgoldgold", "quantity":"1000000.0000 GOLD", "memo":"issue GOLD"}' -p goldgoldgold@active

4- transfer a maximum mirrored supply to eosio.erc2o

./cleos transfer goldgoldgold eosio.erc2o "1000000.0000 GOLD" "eosio.erc2o" -c goldgoldgold -p goldgoldgold

5- deploy the implementation contract (this is done only once for all tokens)

./cleos push action eosio.erc2o upgdevm2nat '[]' -p eosio.erc2o

6- regsiter trustless bridge for the ERC-20 token:

./cleos push action eosio.erc2o regevm2nat '["0x4d9dbb271ee2962f8becd3b27e3ebcd384ad3171","goldgoldgold","0.1000 GOLD","0.0100 EOS",18,""]' -p eosio.erc2o

after that the token bridge is regsitered:

./cleos get table eosio.erc2o eosio.erc2o tokens
{
  "rows": [{
      "id": 2,
      "token_contract": "goldgoldgold",
      "address": "efb6a2241f3cc0e740a9aab830ef729130667574",
      "ingress_fee": "0.1000 GOLD",
      "balance": "0.0000 GOLD",
      "fee_balance": "0.0000 GOLD",
      "erc20_precision": 18,
      "_is_evm_to_native": 1
    }
  ],
  "more": false,
  "next_key": ""
}

7 - to transfer from EVM to native, a user needs to:

  • 7a) call 0x4d9dbb271ee2962f8becd3b27e3ebcd384ad3171's approve(efb6a2241f3cc0e740a9aab830ef729130667574, amount)
  • 7b) call efb6a2241f3cc0e740a9aab830ef729130667574's bridgeTransfer(to, amount, memo), where the "to" is the reserved address that maps to the native account

@taokayan taokayan requested review from yarkinwho, arhag and elmato March 5, 2025 10:25
@taokayan taokayan changed the title Kayan evm2native draft: initial implementation of evm->native bridge Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant