Tellor Playground
This page is designed to give you a quick overview of using Tellor to get data into your smart contracts.
Overview
Why use Tellor Playground?
Why not use the real Tellor
How to use
Reading values
npm install usingtellorimport "usingtellor/contracts/UsingTellor.sol";
contract BtcPriceContract is UsingTellor {
//This contract now has access to all functions in UsingTellor
bytes public btcPrice;
bytes32 public btcQueryId = 0x0000000000000000000000000000000000000000000000000000000000000002;
constructor(address payable _tellorAddress) UsingTellor(_tellorAddress) public {}
function setBtcPrice() external {
// TIP: For best practices, use getDataBefore with a time buffer to allow time for a value to be disputed
(bool _ifRetrieve, bytes memory _value, uint256 _timestampRetrieved) = getDataBefore(btcQueryId, block.timestamp - 2 hours);
if(_ifRetrieve) {
btcPrice = _value;
}
}
}Setting values in the Playground
Available Functions
Last updated