Salt la conținutul principal

Cum să configurați Tellor ca oracol personal

soliditycontracte inteligentefluxuri de prețurioracole
Începător
Tellor
Documentație Tellor(opens in a new tab)
29 iunie 2021
2 minute de citit minute read

Pop Quiz: Your protocol is just about finished, but it needs an oracle to get access to off chain data...What do you do?

(Soft) Condiții prealabile

Această postare își propune să faciliteze și să simplifice pe cât posibil accesarea unui flux de oracol. Acestea fiind spuse, vom presupune următoarele despre nivelul dvs. de cunoștințe de programare pentru a ne putea axa pe partea de oracol.

Ipoteze:

  • știți să navigați într-un terminal
  • aveți npm instalat
  • știți cum să folosiți npm pentru a gestiona dependențele

Tellor este un Oracol live și open-source gata de implementare. Acest ghid pentru începători are rolul de a prezenta cât este de ușor să puneți în funcțiune Tellor, oferind astfel proiectului dvs. un oracol complet descentralizat și rezistent la cenzură.

Prezentare generală

Tellor is an oracle system where parties can request the value of an off-chain data point (e.g. BTC/USD) and reporters compete to add this value to an on-chain data-bank, accessible by all Ethereum smart contracts. The inputs to this data-bank are secured by a network of staked reporters. Tellor utilizes crypto-economic incentive mechanisms, rewarding honest data submissions by reporters and punishing bad actors through the issuance of Tellor’s token, Tributes (TRB) and a dispute mechanism.

În acest tutorial vom trece în revistă:

  • Configurarea unui set inițial de instrumente necesare pentru punerea în funcțiune.
  • Consultarea unui exemplu simplu.
  • Consultarea unei liste de adrese testnet ale rețelelor pe care puteți actualmente testa Tellor.

FolosireaTellor

Primul lucru pe care îl aveți de făcut este să instalați instrumentele de bază necesare pentru a utiliza Tellor ca oracol. Use this package(opens in a new tab) to install the Tellor User Contracts:

npm install usingtellor

Odată instalat, acesta va permite contractelor dvs. să moștenească funcții din contractul „UsingTellor”.

Super! Now that you've got the tools ready, let's go through a simple exercise where we retrieve the bitcoin price:

Exemplu BTC/USD

Moșteniți contractul „UsingTellor”, trecând adresa Tellor ca argument pentru constructor:

Iată un exemplu:

1import "usingtellor/contracts/UsingTellor.sol";
2
3contract BtcPriceContract is UsingTellor {
4
5 //This Contract now has access to all functions in UsingTellor
6
7 bytes btcPrice;
8 bytes32 btcQueryId = 0x0000000000000000000000000000000000000000000000000000000000000002;
9
10 constructor(address payable _tellorAddress) UsingTellor(_tellorAddress) public {}
11
12 function setBtcPrice() public {
13 bool _didGet;
14 uint256 _timestamp;
15
16 (_didGet, btcPrice, _timestamp) = getCurrentValue(btcQueryId);
17 }
18}
Afișează tot
Copiați

Want to try a different data feed? Check out the list of supported data feeds here: Current Data Feeds(opens in a new tab)

Addresses:

Mainnet: 0x88df592f8eb5d7bd38bfef7deb0fbc02cf3778a0(opens in a new tab)

Looking to do some testing first? See the list below for our active testnet addresses:

Rinkeby: 0x88df592f8eb5d7bd38bfef7deb0fbc02cf3778a0(opens in a new tab)

Kovan: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7(opens in a new tab)

Ropsten: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7(opens in a new tab)

Goerli: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7(opens in a new tab)

BSC Testnet: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7(opens in a new tab)

Polygon Mumbai Testnet: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7(opens in a new tab)

Arbitrum Testnet: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7(opens in a new tab)

Pentru o implementare mai robustă a oracolului Tellor, consultați lista completă de funcții disponibile aici.(opens in a new tab)

Ultima modificare: @nicklcanada(opens in a new tab), 13 noiembrie 2023

A fost util acest tutorial?