How and why did I build dogamistats.com

Roughly 3 years ago when I was still in London I started getting attention to the Tezos Blockchain. Since then, I have been looking at his ecosystem and Dogamí is part of it.

What is Dogamí actually ?

Dogami is a unique play-and-earn game based on tezos blockchain where you adopt and raise virtual dogs NFTs. Each dog has its very own attributes, evolving in different stages and able to compete in real-time competitions and events. The better you raise them, the more you earn. From a puppy into your best friend, all your actions will make you earn $DOGA. Moreover, dogamis can also be bred together to produce new and unique offspring, which can be kept or sold on marketplaces.

Quotation by Bilal EL ALAMY - CTO @Dogami

Once I first heard about Dogamí I felt like it was one of the most promising project in the gaming industry and more importantly for the Tezos community.

So it all started that way. A friend of mine and me as part of a week-end were spending together I introduced it about Dogamí and since It was all of our spare time interest and we started diving into it getting more and more interest into Dogamí.

The first mint

So the thing is going on the discord community of Dogamí. Basically what you need to do is taking part of the hype, follow events, be active on their community and if you have some luck you get a Dogalist which is a spot that let you mint (privately or publicly).

The first mint of Dogamí was on the 22.02.22. They were initialy 8000 NFTs to mint. This was a success accross the community and if you had not the chance to be listed to mint your chance to get a Dogamí was through the marketplaces either on Dogami or objkt.com.

https://marketplace.dogami.com/marketplace

objkt.com | The largest NFT marketplace on Tezos
Discover the latest #CleanNFTs on the largest NFT marketplace on Tezos.

The next chance of getting a spot or take part to the journey is 31th of May 2022 where the second private mint will happen check out their discord here:

Join the Dogamí Discord Server!
A play to earn game, on Tezos 👾https://dogami.com/ | 115,417 members
Discord

So back in the day my friend and I had the chance to secure a spot and we mint. However the hype was still there and we were scrutinizing every marketplaces to look at NFT's attribute, rarity and so on. However the missing part was mainly that we had data only on listed Dogami which means only for sale dogami where available but we did not have way to explore or filter data based on already revealed data out of hardcoding and visiting url based endpoints. This is where the dogamistats website came up to our mind. Due to the web3 nature, the fact that every interaction with the blockchain is persisted you can effectively parse the blockchain and extract valuable data.

Note on the reveal aspect of Dogamí's NFT: Basically when you mint a Dogamí it has a set attribute which has as status: Box. You won't get a Dogamí directly but a box where you will be free to open when you want (when the reveal is being "unlocked"). For instance as stated the mint occured on 22 th of February 2022 and first revealed box were on 4th of March 2022.

Dogamí Series 1 Box Status

Dogamistats a prototype

So I started hacking. My first goal was to understand how I can access the blockchain effectively. To do so I've been using:

Better Call Dev
Tezos smart contract explorer and API provider. Easy to spin up / integrate with your sandbox.

Better Call Dev is a smart contract explorer for the Tezos blockchain.

Non-exhaustive definition but basically as an individual or programmer you can easily explore contract, look at their entrypoint or parameters (required/optional) and so on and you can even query it through different way directly from the UI.

So BCD was here to help and go through the Dogamí NFT reveal's data and the good thing is that you can do so through API as a programmer. Then the next thing was to get the attribute bidding from the data to a human-readable one. Then the job is only to traverse the reveal entrypoint, normalize data and use it.

So after a few hours I was able to traverse BCD's api, store some normalized data.

What was needed further down the road:

  • An API to expose that data
  • A frontend to consume that data

Dogamistats the prototype that get into production

So I've started crafting the API locally to do so I've been using the following

To orchestrate and test this locally leveraged a postgreSQL server through a docker-container see docker-compose file down below.keyv

version: "3.9"

services:
  database:
    container_name: "backend"
    image: postgres
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: ***
      POSTGRES_PASSWORD: ***
      POSTGRES_DB: ***
    volumes:
      - ./docker_postgres_init.sql:/docker-entrypoint-initdb.d/docker_postgres_init.sql

So wrote a couple of routes and it was working as expected.

Then had to get started on the Frontend I've used the following:

My app was a single page app, wrote a couple of components tested it out and finally released it.

The last missing piece was actually my scheduled task that fetch new revealed boxes on a daily basis.

To do so I find it quite useful to write a lambda function that was going to do this for me.

The idea is simple:

  1. On a regularly basis, fetch all elements available on blockchain dogami's reveal data.
  2. Do a diff between what we already have into db and what's new
  3. Insert new data

Then my frontend is fully reactive because backend is exposing fresh new and updated data and component are being populated automatically based on attributes and internal avaible data.

Dogamistats.com Infra

How the whole was hosted

  1. Domain name Got the domain name dogamistats.com from https://www.gandi.net
  2. Set up database myself on an instance at https://www.scaleway.com. I did not needed to pay extra money for managed database and also it does not really need to be backup, because all the data is available on blockchain. So even if data get lost and I can recover it quite easily and quickly through the automated script. Set up this through docker.
  3. Set up the frontend on Vercel, pretty easy. Binded the domain name on production + hook when pushing on main branch updating instantly into production.
  4. Initialy set up my backend on Vercel as well for sake of simplicity and it worked and went through defining a node engine and so on. However note that I was not using a single function and basically if I'm not mistaken vercel is not designed for that. So that was my initialy go to solution, but just recently replaced it with fly.io. This service is exactly what I was looking for being able to spawn and host my service right from a git push action, also bind it to a domain through some DNS mechanism and it works like a charm. I had other alternative heroku for example, but I'm finding it too expensive (out of the hobby free plan) and it has also digitalocean which was my initial bet, but failed on the DNS part. So I gave fly.io a go.
  5. Wrote and deployed my scheduled function to AWS with Serverless Framework. Again I could I've deployed to Scaleway Function or any other cloud function based service, but I'm used to work with AWS + Serverless and it was straighforward to do so. Eager to give scaleway a new shot again with serverless to double check how the plugin integration is smoother or not, it was such a pain the other time I tried.

Thanks for reading. I hope you enjoyed that deep dive. Feel free to support me and dogamistats.com while sending some Tezos to the address on the footer. That will help me to support my work and mainly cover the cost of hosting.