Cara Menyiapkan Tellor sebagai Oracle Anda
Pop Quiz: Your protocol is just about finished, but it needs an oracle to get access to off chain data...What do you do?
Prasyarat (perangkat lunak)
Posting ini bertujuan untuk membuat akses ke feed oracle semudah dan sesederhana mungkin. Oleh karena itu, kami menggangap yang berikut ini kira - kira adalah tingkat kemahiran pengodean Anda untuk berfokus pada aspek oracle.
Asumsi:
- Anda dapat menavigasikan suatu terminal
- Anda memiliki npm yang telah terinstal
- Anda mengetahui cara menggunakan npm untuk mengelola dependensi
Tellor adalah oracle sumber terbuka dan langsung yang siap untuk diimplementasikan. Panduan pemula ini ada untuk menampilkan kemudahan yang dengannya seseorang dapat memulai dan menjalankan Tellor, yang menyediakan proyek Anda dengan oracle yang sepenuhnya terdesentralisasi dan tahan penyensoran.
Gambaran umum
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.
Dalam tutorial ini, kita akan membahas:
- Menyiapkan toolkit awal yang akan Anda butuhkan untuk memulai dan menjalankannya.
- Membahas suatu contoh sederhana.
- Merinci alamat testnet jaringan yang dapat Anda gunakan untuk menguji Tellor saat ini.
Menggunakan Tellor
Hal pertama yang akan ingin Anda lakukan adalah menginstal perangkat dasar yang diperlukan untuk menggunakan Tellor sebagai oracle Anda. Use this package to install the Tellor User Contracts:
npm install usingtellor
Setelah diinstal, ini akan memungkinkan kontrak Anda untuk mewarisi fungsi dari kontrak 'UsingTellor'.
Bagus! Now that you've got the tools ready, let's go through a simple exercise where we retrieve the bitcoin price:
Contoh BTC/USD
Wariskan kontrak UsingTellor, yang meneruskan alamat Tellor sebagai argumen konstruktor:
Berikut contohnya:
1import "usingtellor/contracts/UsingTellor.sol";23contract BtcPriceContract is UsingTellor {45 //This Contract now has access to all functions in UsingTellor67 bytes btcPrice;8 bytes32 btcQueryId = 0x0000000000000000000000000000000000000000000000000000000000000002;910 constructor(address payable _tellorAddress) UsingTellor(_tellorAddress) public {}1112 function setBtcPrice() public {13 bool _didGet;14 uint256 _timestamp;1516 (_didGet, btcPrice, _timestamp) = getCurrentValue(btcQueryId);17 }18}Tampilkan semuaSalin
Want to try a different data feed? Check out the list of supported data feeds here: Current Data Feeds
Alamat:
Mainnet: 0x88df592f8eb5d7bd38bfef7deb0fbc02cf3778a0
Ingin melakukan beberapa pengujian terlebih dahulu? Lihat daftar di bawah untuk alamat testnet aktif kami:
Rinkeby: 0x88df592f8eb5d7bd38bfef7deb0fbc02cf3778a0
Kovan: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7
Ropsten: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7
Goerli: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7
BSC Testnet: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7
Polygon Mumbai Testnet: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7
Arbitrum Testnet: 0x3477EB82263dabb59AC0CAcE47a61292f28A2eA7