Try   HackMD

Tellor One-Stop Doc™

The Ultimate Guide to hacking on Tellor
*FVM 2023 Edition

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.

Our bounties for FVM 2023:

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!)

Nowwe build.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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.

In this tutorial we'll go over:

  • Setting up the initial toolkit you'll need to get up and running.
  • An example integration of Tellor.
  • Tipping to get a data report.

UsingTellor

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 :

BTC/USD Price Example

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));
  }
}

To experience using Tellor w/ a demo contract, watch this video tutorial.

Tipping

Testnet Tokens

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:

How to get Test TRB

Use the faucet function on playground's token contract
Click here for more info

How to Tip Reporters:

Via block explorer:

  1. call approve with the tip amount in the token contract

  2. call 'tip' in autopay contract

    *Don't forget to include a link to your tip tx in the read.me of your submitted project.

🎉🎉🎉 Congrats! you're now an official Tellor user!

Need Some Inspiration?

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.

Extra Resources