Hey Hackers! Welcome to your One-Stop Doc™ which includes everything you need to know about getting your hackathon project using Tellor’s oracle and ensuring you have an easy guided path to qualifying for a bounty.
Challenge:
Best use of Tellor oracle in your project built on FVM.
Prize Pool: $2500 (Up to 10 best teams, capped at $1000 per team)
To qualify:
Winners will need to meet these 2 requirements:
✅ Submit link to deployed and verified contract that integrates the “usingTellor” npm package
✅ Submit a transaction hash of a tip to incentivize a report. Use our guide
to configure incentives for tipping/paying testnet reporters to provide your data.
The key take-away is that we want to see true usage of Tellor demonstrated by those two requirements. (Don’t worry, we’ll guide you through it!)
One of the most basic use cases for oracles are spotPrice feeds ( see list of readily available prices ). So this guide will focus on that.
However if you'd like to use Tellor for something that isn't a spot price or it happens to be an asset price not currently supported please use: NumericApiResponse.
NumericApiResponse is a query type specifically for testing that reports numerical values from any API to Tellor oracles. Only use this query type for testing, as data sources with single points-of-failure shouldn't be used in production.
The first thing you'll want to do is install the basic tools necessary for using Tellor as your oracle. Use this package to install the Tellor user contracts:
npm install usingtellor
Once installed, this will allow your contracts to inherit the functions from the 'UsingTellor'. contract.
Great! Now that you've got the tools ready, let's go through a simple exercise where we can retrieve the BTC/USD price :
Inherit the UsingTellor contract, passing the Tellor address as a constructor argument,
Here's an example contract & github repo to follow along with:
contract PriceContract is UsingTellor {
uint256 public btcPrice;
//This Contract now has access to all functions in UsingTellor
constructor(address payable _tellorAddress) UsingTellor(_tellorAddress) {}
function setBtcPrice() public {
bytes memory _b = abi.encode("SpotPrice",abi.encode("btc","usd"));
bytes32 _queryId = keccak256(_b);
uint256 _timestamp;
bytes memory _value;
(_value, _timestamp) = getDataBefore(_queryId, block.timestamp - 15 minutes);
require(_timestamp > 0, "No data exists");
require(block.timestamp - _timestamp < 24 hours, "Data is too old");
btcPrice = abi.decode(_value,(uint256));
}
}
Once you've deployed your contract you'll need testnet tokens to tip reporters. You'll need Tellor Tributes (TRB) for this and of course the native token of your network. Here's how to get some:
Use the faucet function on playground's token contract
Click here for more info
Via block explorer:
call approve with the tip amount in the token contract
call 'tip' in autopay contract
*Don't forget to include a link to your tip tx in the read.me of your submitted project.
Let's start with giving you an idea of what the Tellor oracle can provide…Anything! It just needs to be spec'd out.
But here’s some highlights:
Tellor is extremely flexible, here's a full list of custom query types users have put together in the past here.
Tellor Docs
List of addresses of all the networks Tellor currently supports
Still have questions? Reach out to us in the #sponsor-tellor channel on the #IPFS Discord or Join the Tellor Discord