[COMPLETE] Unwrap FIO Token Prototype

This effort prototypes a simplified end-to-end flow of moving from WFIO to FIO.

Use case

Unwrap FIO Token:

  1. Alice (dApp) executes ERC20 approve sending amount and FIO Address

    1. Send FIO Address as hash?

    2. Add on to end of approve?

  2. Oracle monitors approve

  3. Oracle calls burnFrom from Alice’s account

  4. Oracle calls fio.oracle unwraptokens which transfers FIO to Alice

Assumptions

  • Assume there is a single Oracle managing all transactions. Do NOT worry about multisigs, approvals, etc.

  • No validation on either chain is required.

Diagram link: https://app.diagrams.net/#G1ETfA3K6VTa-rhqcH7gJmRsFUIiGS2kDn

Discussions and Todo

  • Need to create a dapp to interact with erc20 contract. Currently using: https://oneclickdapp.com/matrix-second

    • The complexity of this depends on how we structure the ERC20 contract. If we update the contract with all of the fields needed (e.g., passing in a FIO Address to approve) we may be able to use a simple contract explorer.

Passing FIO Address into approve

  • Discussed using (hashed) FIO Address versus FIO Public Key.

    • A hashed address will generally be smaller and is a known fixed size.

    • To use a FIO Pub Key we would need to convert the pub key to a raw ecc pubkey so we can fit it in 32 bytes, otherwise it's 56 -> padded to 64 and we end up adding even more gas

    • The “standard” in FIO is to use FIO Pub Key

    • The oracle does a validation check on the FIO Address

    • Decided that we would pass in a (hashed) FIO Address to the ERC20 contract

    • TBD: Does the oracle pass a FIO pub key into unwrap tokens?

  • How to pass in FIO Address