Chainlink: How Oracle Machines Connect Blockchain and the Real World

robot
Abstract generation in progress

The Importance of Oracle Systems in Blockchain and the Implementation Mechanism of Chainlink

Oracle Machine is a key infrastructure in the blockchain field, capable of providing external information for on-chain smart contracts. As middleware connecting smart contracts and the external world of the blockchain, the Oracle Machine plays a crucial role, with its main function being to provide data for smart contracts on the blockchain.

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

Oracle Machine Detailed Series: Chainlink (Part 1)

Chainlink is currently the largest Oracle Machine project in terms of market share in the Blockchain field. It is a decentralized Oracle Machine system designed to provide data generated in the real world to the Blockchain in the most secure way. Based on the fundamental principles of Oracle Machines, Chainlink has built a healthy ecosystem driven by economic incentives through the LINK token. Chainlink Oracle Machines need to be triggered by the transfer of LINK tokens, and LINK is an ERC677 contract on the Ethereum network. The Oracle Machine functionality implemented based on the LINK ERC677 token operates in a request/response pattern.

Oracle Machine Detailed Series: Chainlink (Part 1)

The ERC677 token standard was proposed by Chainlink to meet the needs of Oracle Machine service scenarios. It adds the transferAndCall method on top of the standard ERC20, combining payment and service requests into one. When a user transfers through transferAndCall, in addition to the ERC20 transfer functionality, it checks whether the receiving address is a contract address. If it is, it calls the onTokenTransfer method of that address.

Oracle Machine Detailed Series: Chainlink (Part 1)

In the implementation of Chainlink, when the oracle consumer uses the transferAndCall method to pay the fee and request services, the onTokenTransfer method of the oracle 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 the limit, and validating the function selector, among others. After the checks pass, it will call the oracleRequest method of the current oracle contract through deleGatecall.

Oracle Machine Detailed Series: Chainlink (Part 1)

The oracleRequest method generates a unique requestId, sets an expiration time, and adds relevant information to the commitments mapping. Most importantly, it emits an OracleRequest event, which contains the request data represented in CBOR( concise binary object format encoding.

![Oracle Machine Detailed Series: Chainlink (Part 1)])https://img-cdn.gateio.im/webp-social/moments-dae23b36c6a83626aa95ba58fa8dbee5.webp(

Off-chain nodes will listen for these OracleRequest events. When a new request is detected, the node will parse the information in the event, retrieve the required data through API calls, and then submit the data on-chain by calling the fulfillOracleRequest method of the oracle contract. This method will perform a series of validations and then call the callback function of the requester contract to return the result to the consumer contract.

![Oracle Machine Detailed Series on Chainlink (Part 1)])https://img-cdn.gateio.im/webp-social/moments-1994fff156354700fda0609f9e317726.webp(

For developers, if they only need to use the existing currency pair prices, they can directly use the Price Feed provided by Chainlink, also known as Aggregator ). Each trading pair has a separate Price Feed, which is actually an AggregatorProxy contract. These contracts provide several query methods, including obtaining price accuracy, description, version, and the latest price data. In most application scenarios, the contract may only need to read the latest price, that is, calling the latestRoundData ( method.

![Oracle Machine Detailed Series: Chainlink (Part 1)])https://img-cdn.gateio.im/webp-social/moments-bb84d77f358852f47e9adf3e74ba5bf9.webp(

It is worth noting that for trading pairs priced in USD, the price precision is usually standardized to 8 decimal places, which simplifies the issue of precision handling between different tokens. This design allows developers to conveniently use real-time price data in smart contracts without having to deal with complex API calls and data format conversions.

![Oracle Machine Detailed Series - Chainlink (Part 1)])https://img-cdn.gateio.im/webp-social/moments-527bd8714534f5f06ccdd9afe40b253a.webp(

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
  • 8
  • Share
Comment
0/400
staking_grampsvip
· 17h ago
Want to top up Link?
View OriginalReply0
DegenWhisperervip
· 07-13 10:58
Chainke is really good, it's just a bit expensive.
View OriginalReply0
MidnightSnapHuntervip
· 07-13 10:57
Chainlink is quite reliable.
View OriginalReply0
HalfPositionRunnervip
· 07-13 10:57
It feels like link still needs to rise.
View OriginalReply0
GweiTooHighvip
· 07-13 10:52
Has link risen again? No need to guess.
View OriginalReply0
SelfRuggervip
· 07-13 10:46
link bull awesome Just buy it and that's it.
View OriginalReply0
GweiWatchervip
· 07-13 10:41
So good! This price feed is really useful.
View OriginalReply0
PermabullPetevip
· 07-13 10:40
link is very stable
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)