Better Programming

Advice for programmers.

Member-only story

How to Retrieve Price Data in Smart Contracts

Get crypto prices in a single function call

Alex Roan
Better Programming
Published in
4 min readJul 30, 2020

--

Photo by Miloslav Hamřík on Pixabay.

The price of a LINK token has all but doubled in the past month, moving from around a steady $4 to a whopping $8 in a very short time. This is in no small part down to the Chainlink Oracle network, which provides a platform to call any external API from within smart contracts as well as a Verifiable Random Function for Solidity.

While both of these products are extremely powerful tools, they follow the Request & Receive cycle, which is not instantaneous. This means that any smart contract using them has to request the data in one transaction, then wait to receive the response in another.

This is great, but there is an even faster way to retrieve off-chain data in a single transaction.

The Need for Speed

At the time of writing, the amount of value locked in the DeFi ecosystem is over $3 billion. But what does “locked up value” mean for those of us who are unfamiliar with the economics?

Essentially, it represents collateral for other assets, like stable coins. Any decentralised stable coin has other assets backing it, so if anyone wants to redeem their coin for fair value, they can.

How to print money

--

--

Alex Roan
Alex Roan

Written by Alex Roan

CoFounder at Cyfrin. Previously: Chainlink Labs.

Responses (1)