Unwrap
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.
Decide on how to pass in FIO Address (see below)
Use case
Unwrap FIO Token:
Alice (dApp) executes ERC20
unwrap
sending in a hashed FIO AddressERC20 calls
burn
from Alice’s accountOracle monitors
unwrap
When ERC20
unwrap
event is seen, Oracle validates and calls fio.oracleunwraptokens
fio.oracle contract collects Oracle
unwraptokens
observations (consensus)When consensus is reached fio.oracle executes
unwraptokens
Diagram link: https://app.diagrams.net/#G1ETfA3K6VTa-rhqcH7gJmRsFUIiGS2kDn
Discussion
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
Decision: We will 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
The current approach does not modify the ERC20
approve
function. It appends the hashed FIO Address to the transaction:Convert the i128 hash to bytes, left pad with zeros until it's 32 bytes long, tack it onto the end of the transaction data, sign and send
Here is the encoding: https://github.com/blockpane/fio.oracle/blob/main/internal/util/eth.go#L206
An example of sending the data: https://github.com/blockpane/fio.oracle/blob/main/internal/util/eth.go#L423
Decision: Adam will create an
unwrap
function that accepts a hashed FIO Address