Today we will talk about Link, which ranks around 23rd in market value. Its current market value is about US$4 billion. It is a project that I am seeing that excites me so far, because it connects the real world and the blockchain world, and builds a bridge from the real world to the blockchain world, not to mention in the blockchain world. If you cross one floor, it's at least half a floor. Later I will explain to you exactly what he did.
Let me give you an introduction first. This issue may contain a lot of content. Chainlink is a project launched in 2017. It has already launched the Ethereum mainnet and a pledge agreement. ChainLink provides "smart contracts" for the blockchain. The middleware that calls external data provides contract makers with a network-wide database, or it can be called a reliable external database.

Opening its official website, his solgan is to connect the world to the blockchain. His goal is to connect the world's people, businesses and data to the web3 world using industrial web3 service standards.
Next, let’s take a look at his white paper, which is also the longest white paper I have read so far, with more than 100 pages. Here we have to mention why there is such a thing as an oracle.
We know that in the blockchain it is a closed system, because each transaction is initiated by a node in the network and then written to the ledger of the blockchain. This is of course no problem because the blockchain is It is centralized, and there are many nodes to maintain this ledger. Of course, the POW mechanism also allows many people to spend a lot of money on maintaining it, so there is no double spending, non-performance, etc., so in blockchain 1.0 There is no counterparty risk, which is the risk of the counterparty running away and not performing the contract.
But in Blockchain 2.0, smart contracts appeared. Smart contracts require data (such as flight departure information) to execute commands, but real-world protocols and most of the data are not stored on the blockchain. Smart contracts also cannot access external data because the blockchain is like a black box with no built-in ability to connect to the outside world. This means that asset prices, sports scores, Internet of Things (IoT) sensors, network data, enterprise systems, and numerous other real-world data sets simply cannot be used on the blockchain, severely limiting the types of smart contracts developers can create. . For example, how to formulate a flight insurance agreement without flight data? Another example is that you specify a delivery contract, and someone else delivers the goods to you. After you receive the goods, you automatically transfer the money to the other party's account, but the smart contract How to tell whether you have received the goods? A smart contract is a piece of programming code that cannot interact with the real world, that is, it cannot obtain off-chain data. Therefore, the emergence of smart contracts has brought in competitor risks.

So this requires something called an oracle machine, which can write off-chain data into the blockchain. In addition to the most widely used price data, it also includes some weather data, sports game data, stock market data, traffic data, and even presidential election results.
In addition to providing data, the broad functions of oracles also include providing random numbers and serving as triggers to implement smart contract execution. They are all considered off-chain tools to interact with on-chain contracts.
But there is another problem with oracle machines, that is, oracle machines are divided into centralized oracle machines and decentralized oracle machines. If it is a centralized oracle machine, a big problem is that it has the risk of a single point of failure. When users deploy smart contracts on the blockchain, their original intention is to have numerous nodes in the blockchain network ensure the security and fairness of the contract. Under this premise, for external data, the data that the contract relies on is input through a centralized service, which will lead to a reduction in overall security. And this is also very unblockchain, because it is no different from centralized things. Moreover, once the network fails with a centralized oracle, it will cause the loss of business terminals, user data, etc. These are very serious problems.
So now we need a decentralized oracle, then it is chainlink.
Chainlink is a decentralized oracle network developed to allow smart contracts to automatically transfer data between blockchains and external systems in a highly secure and reliable manner. There are many oracle nodes in the network. Each oracle node can obtain data through its own channels, and then reach consensus on the obtained data in the decentralized network. The consensus method here is not a consensus in the sense of BFT, POS, or POW, but to obtain reliable data, such as taking an average; or similar to a sports competition, removing the highest score, removing the lowest score, and the remaining Take the average or median. Now Chainlink adopts the median consensus method.
Chainlink puts oracles through a decentralized network, technically avoiding the risk of single points of failure. Just like Ethereum nodes, when a node is interrupted or exits, it will not affect the security and availability of the entire network. In addition, since this data uses multiple data sources, it will not be manipulated by one unilateral data source, taking full advantage of the advantages of decentralization.
ChainLink has three key components; on-chain oracles, off-chain oracles, and ChainLink nodes.
ChainLink’s on-chain oracles are smart contracts that connect requests for information to the appropriate off-chain oracles. These contracts are used to aggregate data, check the reputation of oracles, and match the correct requests.
Off-chain oracles are oracles responsible for providing information to the blockchain. They are equivalent to validators/miners in other blockchains. These oracles stake LINK to act as oracles and receive LINK in return for performing this service. ChainLink keeps oracles honest by verifying data with each other and punishing oracles with incorrect data. It also sends requests for information to numerous validators to ensure it is accurate.
Chainlink currently launches data feeds, VRF (verifiable random numbers), automated contract execution and other services.
1. In Chainlink Data Feeds, different oracle nodes obtain price data through their own data providers, and then aggregate multiple data through the oracle network. For example, for a token price, node A's quote is $400, node B's quote is $399, and node C's quote is $401. After the oracle node agrees on all the quotes, it will pass the median price of $400 to the smart contract on the chain, and complete This price feed.
Data Feeds Business Process
The business process of Data feeds involves two parties. The first is the data provider, which uses its own data or obtains the corresponding data through a third party, and then inputs it into a node in the Chainlink oracle network. Another participant is the oracle node. Each node can have one or more data providers. The data input by each provider will be consensused in the oracle network, and then a node will be randomly selected in the network. Nodes submit data to the chain.
Use case
One of the most common application scenarios is lending protocols, such as AAVE, Compound on Ethereum, and Venus on BNB. When a user deposits a BTC on AAVE and then lends out USD, AAVE needs to know the exchange ratio between BTC and DAI in order to decide how much USD to lend to the user.
The second application scenario is synthetic assets, such as Synthetix (SNX), which allows users to trade some mainstream assets, such as US stocks. When users synthesize assets, the protocol definitely needs to know the asset price, which is obtained through Data Feeds.
The third application scenario is mortgage-type Stablecoin. If mortgaged Stablecoin is to be issued, corresponding assets need to be mortgaged. The Stablecoin protocol needs to obtain the price of the asset through Data Feeds before it can calculate the total value of the mortgage assets and determine the issuance quantity of Stablecoin based on the total value.
The fourth is an asset management and derivatives trading platform. Trading platforms such as options and futures are very sensitive to price and need to provide stable and accurate price data. The data provided by Data Feeds perfectly meets their business needs.

2.Chainlink Keepers is a decentralized contract execution service that can realize automated execution of contracts on the chain.
The development team can register an UpKeep, and the monitored contract status will be detected in each block. If the preset conditions are met, the function will be called. Of course, the preset conditions may not be set (equivalent to the condition judgment result being equal to True). , to call specific functions in specific contracts based on time.
Chainlink Keepers can continuously detect the status of smart contracts based on preset logic without requiring input. If it is satisfied, it will be executed. If not, it will wait for the next detection.
Use case
The first application is automatic compounding. Many DeFi applications will pay interest to deposit users. If the user does not withdraw money, it is equivalent to simple interest. Simply put, it is the interest earned for one year after depositing for one year. If the user withdraws the interest generated at regular intervals and then deposits it for compound interest investment, the income can be maximized. This withdrawal and deposit operation is a fixed operation based on time, which can be completed through Keepers. Projects such as Beefy, Alchemix, SNX, etc. all use Keepers to complete this compound interest investment.
The second application is the liquidation of lending platforms, such as AAVE and B-protocol. When the price of the user's pledged assets in the protocol drops and falls below the warning line, the protocol needs to liquidate the collateral to avoid further losses. According to this scenario, the checkUpKeep function can write the clearing price of the subject auction, and performUpKeep can write the specific clearing logic. When checkUpKeep returns True, Keepers automatically execute performUpKeep to liquidate pledged assets.
The third application is DEX limit order. The Automatic Market Maker (AMM) used in DEX is different from the order book model of centralized exchanges and has no way to place limit orders. If you want to use limit order, you need to write your own logic. When the token price is lower than a certain threshold, buy or sell it, that is, use Keepers, write judgment logic in checkUpkeep, and write execution logic in performUpkeep.
The fourth application is liquidity management and cross-chain NFT casting. For example, in Polygon mint, an NFT (because Ethereum mainnet gas is more expensive), gets the ID or features attribute value (whether it is rare or not), this value can be obtained through relay Write it back to the main network to help users achieve cross-chain casting of NFT.
The fifth application is dynamic NFTs. Its logic is that NFTs on the blockchain will change as related properties change in the real world. For example, weather NFT, if it rains outside, the NFT will show rain, and if the outside is hot, the NFT will show a sun. Obtain data from the outside and make some changes based on the acquired data. Keepers are frequently used here.
3.Chainlink’s third decentralized product is Verifiable Random Number VRF. Before the emergence of VRF, the mainstream method of generating random numbers was to generate a Hash based on the transactions in the current block, and use this Hash as a seed to generate random numbers, which led to problems. Miners can selectively package transactions and get the random numbers they want. Although the cost is relatively high, when the profit return is high, the possibility of miners doing evil will also increase accordingly. The generation of random numbers is also an uncertain operation. Because the generation of random numbers is unpredictable, different nodes will definitely get different results when executing the random number algorithm, which will cause transactions. The execution results are inconsistent and consensus cannot be reached.
By inputting verifiable random numbers through an external oracle, allowing the smart contract on the chain to only accept and verify the random numbers, the consistency of transaction execution can be ensured. At the same time, it can also be realized that the random number cannot be predicted in advance, and its security can be guaranteed through proof.
In Chainlink VRF, random numbers are generated by the oracle network. The user inputs a seed to the VRF contract, and the oracle VRF node will use the node private key and seed to generate a random number and Proof (proof) and return it to the VRF contract. The VRF contract Proof verifies the legality of the random number. If it passes the verification, it will Return a random number to the user. Different from purely off-chain random numbers, the random numbers generated by Chainlink VRF can be proved by Proof that they are calculated based on a specific elliptic curve algorithm and are verifiable and unique.
scenes to be used
The current largest application scenario of Chainlink VRF is NFT Mint. NFT needs to be created and distributed. When created, each NFT has a different rarity and is allocated to different users. Depending on business needs, you may also need to set up a whitelist, and the holders in the whitelist will airdrop different NFTs. For example, the Boring Monkey Project airdrops serum to the Holder. The random airdrop of the serum uses VRF random numbers.
Another application is lottery. For example, on some IDO platforms, users purchase tokens and then pledge the tokens. The platform will give away whitelists to participate in the lottery, and the size of the reward can be selected using VRF.
ChainLink is one of the most exciting blockchains because it bridges the real world and the crypto world. This is a great solution, especially now that we are also emphasizing the Internet of Things (IoT), so with the development of the Internet of Things , with the development of the blockchain industry, there may be more blockchain applications in our society in the future, decentralized sports lottery systems, decentralized insurance business, decentralized second-hand car business, etc., So this track really deserves attention. If the students of this episode listened carefully and took it in, then you should know what to do. Okay, that’s all for this episode.


