How Oracle Machines Become the Data Bridge Between Blockchain and the Real World

robot
Abstract generation in progress

Oracle Machine: The bridge connecting Blockchain and the real world

In Blockchain technology, Oracle Machine plays a crucial infrastructure role. It is a system that can provide external information to on-chain smart contracts, acting as middleware between the Blockchain and the external world. The main function of the Oracle Machine is to provide the necessary external data for smart contracts on the Blockchain.

For example, suppose we create a smart contract on the Ethereum network that needs to obtain the crude oil trading volume data for a certain day. Since the smart contract itself cannot directly access this off-chain real-world data, it needs to use an Oracle Machine to achieve this. In this case, the smart contract will write the required crude oil trading volume data into the event log. Subsequently, an off-chain process will be initiated to monitor and subscribe to this event log. When a request from the transaction is detected, the process will submit an on-chain transaction to call the relevant methods of the contract, uploading the crude oil trading volume information for the specified date into the smart contract.

Oracle Machine Detailed Series: Chainlink (Part 1)

Chainlink: The Leader of Blockchain Oracle Machines

In the field of Oracle Machines, Chainlink is undoubtedly the project with the largest market share. As a decentralized Oracle Machine solution, Chainlink aims to provide data generated in the real world to the Blockchain in the most secure way. Based on the basic principles of Oracle Machines, Chainlink has built an ecosystem around the LINK token that forms a virtuous cycle through economic incentives.

Oracle Machine Detailed Series: Chainlink (Part 1)

The activation of the Chainlink Oracle Machine requires the transfer of LINK tokens. LINK is an ERC677 contract token based on the Ethereum network. The oracle functionality completed with LINK ERC677 tokens belongs to the request/response model.

transferAndCall in ERC677 token

The ERC677 standard was proposed by Chainlink to adapt to the Oracle Machine service scenario. It adds the transferAndCall method on top of the standard ERC20, combining payment and service requests into one, meeting the needs of the Oracle Machine business scenario.

When users make transfers using transferAndCall, in addition to the standard ERC20 transfer, it will also check whether the receiving address is a contract address. If it is, it will call the onTokenTransfer method of that address. It is important to note that before requesting Oracle Machine services, users should first confirm the credibility of the Oracle Machine, as the Oracle Machine service requires prepayment.

Oracle Machine Detailed Series: Chainlink (Part 1)

On-chain Oracle Machine request process

When Oracle Machine consumers use the transferAndCall method to pay fees and request services, the onTokenTransfer method in the Oracle Machine contract will first perform a series of security checks. This includes verifying that the transfer is in LINK tokens, checking if the data length exceeds limits, and validating that the data contains the correct function selector, among others.

After passing the security check, the contract will generate a unique requestId and set the expiration time for the request. Finally, the contract will emit an OracleRequest event, which contains the detailed data of the request.

Oracle Machine Detailed Series: Chainlink (Part 1)

Off-chain Node Response Mechanism

After the off-chain node receives the OracleRequest event, it will parse the specific information of the request and obtain the required data through network API calls. Subsequently, the node will call the fulfillOracleRequest method to submit the data on-chain.

This method will perform a series of validations, including checking whether the caller is authorized, verifying the validity of the request, etc. After the validation passes, the contract will record the amount of tokens that can be withdrawn and remove the requestId from the commitments mapping. Finally, the contract will call the callback function of the requester's contract to return the data to the consumer.

Oracle Machine Detailed Series: Chainlink (Part 1)

Price Oracle Machine's practical application

For developers, if you only need to use the existing price data of currency pairs, you can directly use the Price Feed interface provided by Chainlink. Each trading pair has a separate Price Feed (, also known as Aggregator ), which is actually an AggregatorProxy contract.

These interfaces usually provide the following query methods:

  • decimals(): Returns the precision of the price data.
  • description(): Returns the trading pair name
  • version(): Indicates the type of Aggregator pointed to by the Proxy.
  • getRoundData(_roundId): Retrieve price data for a specific round.
  • latestRoundData(): Get the latest price data

In most application scenarios, the contract may only need to read the latest price, which is to call the latestRoundData() method. The returned answer parameter is the latest price.

It is worth noting that the token prices read by most applications are denominated in USD. In this case, the precision is usually standardized to 8 decimal places, which simplifies the precision handling issues between different tokens.

Oracle Machine Detailed Series: Chainlink (Part 1)

LINK0.51%
View Original
This page may contain third-party content, which is provided for information purposes only (not representations/warranties) and should not be considered as an endorsement of its views by Gate, nor as financial or professional advice. See Disclaimer for details.
  • Reward
  • 7
  • Share
Comment
0/400
nft_widowvip
· 4h ago
Oracle Machine amazing This can just walk sideways!
View OriginalReply0
CountdownToBrokevip
· 4h ago
just a passerby on the chain
View OriginalReply0
BlockchainBouncervip
· 4h ago
Quack quack, here to explain the Oracle Machine mechanism again!
View OriginalReply0
StakeTillRetirevip
· 4h ago
The Oracle Machine is really great, my smart contracts can't be without it.
View OriginalReply0
FUD_Whisperervip
· 5h ago
I can't even afford to eat contract meals.
View OriginalReply0
HalfPositionRunnervip
· 5h ago
This fried oil data relies on the Oracle Machine to save it.
View OriginalReply0
ImpermanentPhilosophervip
· 5h ago
Tsk, it's the Oracle Machine's old story again.
View OriginalReply0
Trade Crypto Anywhere Anytime
qrCode
Scan to download Gate app
Community
English
  • 简体中文
  • English
  • Tiếng Việt
  • 繁體中文
  • Español
  • Русский
  • Français (Afrique)
  • Português (Portugal)
  • Bahasa Indonesia
  • 日本語
  • بالعربية
  • Українська
  • Português (Brasil)