Been wanting to write this update for a long time. The Penny Oracle that I launched on the Theta blockchain is now auto-updated. In other words, I no longer have to manually update the price for minting any of my NFTs in any of my projects. This automation is a huge psychological win for me. Kinda makes me feel like the code is actually doing something useful.
Note that all the projects that use the Selene Network (distributed sales network) NFT functionality use a Penny Oracle. And, in order for a creator to stay in charge of their project pricing, they would either launch their own, or use a trusted Penny Oracle. If they use my official one, the price is kept current (automagically).
What is a Penny Oracle?
The Penny Oracle provides the amount of Wei that represents a penny’s worth of Tfuel.
Why is it useful?
People that visit my projects think in dollar terms. The Penny Oracle is used by the smart contracts so that they have a current ‘close enough’ representation of the amount of tfuel that it takes to buy their NFT.
By having a relatively accurate price for my NFTs, the value exchange that I’m looking for can be stated in dollar terms rather than Tfuel Wei.
How does this magic work?
The first step comes from a little program that makes API calls to a number of different exchanges that allow for the trading of different Tfuel pairs. From that, the software determines the average price at that current moment. If the code determines that the price has change enough, (three percent from the previous recorded price,) it signs a transaction and posts it to the block chain.
How can you view this?
Well, here is the contract address for the Penny Oracle Version 1:
0x945c5b985a0d4ba6c42a88c1330bded9cd442389
If you look at it’s transactions, you can see that the automation has just recently started. Each time the smart contract is updated, the price averaging code sends the current dollar price of Tfuel and the Wei that represents a penny’s worth of Tfuel.
If you want to view the values that are reported by the smart contract, you can do so by visiting the Interact with a Smart Contract page on ThetaScan.io and use the following ABI to go with the contract address above.
ABI:
[{“inputs”: [],”name”: “pennyPriceTfuel”,”outputs”: [{“internalType”: “uint256″,”name”: “_pennyTfuelWei”,”type”: “uint256”},{“internalType”: “string”,”name”: “_priceOfTfuel”,”type”: “string”}],”stateMutability”: “view”,”type”: “function”}]
When you read this function (pennyPriceTfuel) you’ll see that it returns two items: _pennyTfuelWei and _priceOfTfuel.
How can you help?
The wallet that broadcasts the updates for the Penny Oracle is projected to burn through 125 Tfuel per year. Because this is publicly accessible for any smart contract on chain, if you find it valuable, please support the project.
The Wallet that performs the broadcast updates would be gracious for you Tfuel love:
0x5673DdA6820E986F6fC77087504873B116A4D52c
If I can raise more than one thousand Tfuel, I’ll see about modifying this code to update other crypto currencies too.
How robust is this?
Would like to say that it’s failsafe, but nothing is.
In order for the Penny Oracle to get updated, the software on my machine has to run. With means, if the power grid goes down for me, the Penny Oracle will still report the older update.
The current design limits the number of updates to no more than 1 time every four hours and only if the price has moved more than 3% from the last recorded time. Simulation testing has shown that on average, the price will get updated about every 14 hours.
It shouldn’t take long before there will be enough transactions on chain to confirm this average update period.
The best news is that I’m motivated to make sure that this Penny Oracle stays current for the price it reports is what all my projects use.
What’s next?
Now that this automation is running, it’s time to refocus on smart contract functionality. It’s time to have a little fun with things.