Skip to content

implementation of evm->native bridge #70

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

Merged
merged 11 commits into from
Mar 20, 2025
Merged

implementation of evm->native bridge #70

merged 11 commits into from
Mar 20, 2025

Conversation

taokayan
Copy link
Contributor

@taokayan taokayan commented Mar 5, 2025

Resolves #61 & #63 & #64

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

8 - to transfer from native back to EVM (memo = EVM token receiver address)
./cleos transfer nativeuser1 eosio.erc2o "1.0000 GOLD" "0xaAE508DCac0E36091127cEdaD989649bA601947b" -c goldgoldgold

@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
@taokayan taokayan changed the title draft: initial implementation of evm->native bridge implementation of evm->native bridge Mar 13, 2025
@taokayan taokayan merged commit 22d4094 into main Mar 20, 2025
4 checks passed
@taokayan taokayan deleted the kayan_evm2native branch March 20, 2025 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants