aelf Oracle Episode 2: What did aelf oracle do in the mainnet swap?

Some of you guys have swapped mainnet tokens and have participated in the raffle on our website in recent days. How do you like it? Cheap and fast isn’t it? aelf oracle helped. When swapping ERC-20 ELF to mainnet ELF tokens, aelf oracle helps retrieve the LockMapping contract from Ethereum to aelf mainnet so that users could swap their ELF tokens.

SEND: Create off-chain data

Here is the off-chain data is created for the aelf oracle organization on the website.

Enter the amount of ELF and click “Lock”, a transaction will then be sent to the LockMapping contract of Ethereum. The transaction name is createReceipt. This transaction only accomplishes two things:
- Transfer the amount of ELF entered by the user from the user’s Ethereum account to the LockMapping contract;
- The LockMapping contract creates a receipt for the user.

The hash value of each receipt delivers two messages:
- The number of ERC-20 tokens locked;
- The aelf address to receive the tokens.

TRANSMIT: aelf oracle to retrieve off-chain data

One node within the organization will query the contract every one minute or so. When the node finds that a new receipt is created in the LockMapping contract, it will initiate a Query to fetch data.

For example, if the aforementioned oracle node discovers that Ethereum has recently created five new receipts with receipt ids ranging from 101 to 105, then the query_info of this Query transaction is set as:
- Title: record_receipts
- Options: [101, 105]

Also, the callback information (callback_info) is the way to execute the RecordReceiptHash in the Bridge contract. After the Query transaction whose title is “record_receipts” is packaged into a certain block, the corresponding QueryCreated event will start. Subsequently, the aelf oracle node will update the hash value of the 5 receipts (101–105) to the Bridge contract. And finally, users ...

-----
To keep reading, please go to the original article at:
Stories by ælf on Medium

Comments (No)

Leave a Reply