The Penny Oracle on Theta

The Penny Oracle for Tfuel is now auto-updated. When the price changes more then 3% over 4 hours, the blockchain gets updated.

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 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. 

Marketplace Solutions for the NFT Creator

The old-school brick-&-mortar approach of forcing a creator to ‘fit the mold’ with regards to content creation and distribution is quickly becoming a thing of the past. As technology advances, more creators are going to find that there are alternative paths for content distribution that don’t involve large, centralized organizations.

Ultimately, I’d love to see more creators leverage the power of blockchain to incentivize perfectly good strangers to sell their project for them. This is why I put together the Selene Network (DSN). The network protocols allow creators to own and manage their content while also incentivizing others in a trustless manner.

The latest addition to my Selene Network collection of demos is the ‘NFT with Marketplace demo Version 1’. This NFT has a built-in secondary marketplace.

Imagine being a creator and offering a NFT collection that represents 100 pieces of something unique. Say, every day the creator posts something new to the collection. If this demo code is used (and slightly modified), not only would the creator be able to incentivize sales, but they would have a built-in marketplace where the unique items could trade.

No need for a third party centralized website. Instead, the functionality can be served right off the creator’s own website where there is a high level of trust in the content (and means to the content).

Take a look

So, install MetaMask and instruct it to connect to the Theta Network. Once you have, connect it to this website (AmorStyle.com) and visit:

NFT with Marketplace Demo Version 1

If you would like to see other examples built on the Selene Network core code, visit:

Selene network – In The Gallery

Contacts

Feel free to tag me on Twitter @AmorStyleYoga. Every sample that I create is available for download and review. See the project JSON file for details.