Beta Release of Beta

post image

Introduction

While working on assignments during the past weeks, a question wandered in the back of my mind: what’s next for FireAcademy.io? I can confidently say that, after the last update, making RPC calls is easy, cheap, and fast. It’s not that I don’t see areas of improvement in the current infrastructure, but spending months for a 10% price decrease and a 50ms reduction in response times is not the best path forward (maybe when I get an intern…). Then something unexpected happened. Someone gave me a fascinating improvement suggestion. The more I thought about it, the more it made sense.

There was, however, one significant roadblock: the feature required having up-to-date data about NFTs. The lightbulb moment came when I realized that sometimes I present FireAcademy.io as providing data about the Chia blockchain. RPC calls are nice, but limited: they tell you that a coin was spent, but not if the spend was a CAT transfer, an NFT being minted, or a DID metadata update.

At the moment, I think that this is the best direction forward. The roadblocks that made FireAcademy.io’s RPC services inaccessible - cost and slow responses - are no more. Our mission is and always was to make developers’ lives easier - ‘parsing’ the blockchain is the next logical step.

I also want to mention that our business model will remain unchanged. Everything I code remains open-source, including the updated k8s config, the beta syncer, and beta itself. Self-hosting is always an option - FireAcademy.io just makes it easier to start out. It also lets you sleep worry-free at night, knowing that I’ll handle any problem that might arise.

Beta

Ok, great, blockchain parsing. But how will that work exactly? I’m glad you (rhetorically) asked.

In short, there are three components at work:

  • syncer: Slow, but smart. Responsible for processing blocks and populating the database with parsed data. For Beta, the syncer currently tracks singletons. It’s written in python since it needs to use the ‘chia-blockchain’ library.
  • database: The thing that takes a lot of time to build. It stores the parsed data, along with sync information. Special thanks to acevail for this idea, which makes handling reorgs a piece of cake.
  • client: Fast and stupid. The client is responsible for handling API requests. I wrote it using go-fiber, an extremely fast and lightweight Go web framework that is very similar to Express. The resulting program can be compiled into a stand-alone binary and run inside a scratch Docker image. A single instance can handle tens or even hundreds of requests per second with only 1 virtual CPU and new instances can be spun up in seconds.

So, why singletons? First, several previous experiments have failed. I chose something relatively simple to ensure I don’t waste a lot of time. Good news: Beta works! Second, the singleton top layer is used for both NFTs and DIDs. A future application could sync from Beta instead of Leaflet. This would make coding it extremely simple since Beta takes care of all of the ‘singleton layer stuff.’

Available Endpoints

The main endpoint is get_singleton_states. Singleton states are a way of viewing singletons: when a coin that represents a singleton is spent, the singleton might either get melted or ‘move on’ to one of the coin’s children. Both these events represent a change in the singleton state, which contains information about the current ‘state’: coin information, inner puzzle hash, etc. There are a lot of optional arguments that let developers filter the results. If you are only interested in a single singleton, for example, you can use the launcher_id argument to limit the results to those with the same launcher id. You can also order results and limit the number of returned states.

Singletons also reveal their inner puzzles when they get spent. Use the get_puzzle endpoint to convert an inner puzzle hash to a puzzle if it was revealed in a past transaction.

There are also a lot of sync-related endpoints available: you can get the peak synced block, the block at a given height, or blocks at given heights expressed as a range.

Click here to access the docs. If you have an API key, use this link to play around with the API - just choose an endpoint and click ‘Try it out’! If not, just create a free account here.

What’s Next?

Who knows? New endpoints, DIDs, NFTs, something completely different, or all of these? PM me if you have any ideas or requests.

now please excuse me but I am going back to sleep

Until next time, hack the world.

yakuhito, over.

Published on December 19, 2022