0

I have created a local baker node and run tezos using "./tezos-node run" command. Now I want to store all blocks information into a database and show it to my website. Please help me with it. Thanking you in advance.

1 Answer 1

3

Technical answer:

You have to:

  • fetch successive blocks with RPC /chains/main/blocks/<head|block_hash>
  • process new blocks on the fly, and eventually get back until the genesis block
  • store the blocks' data in a DB at your convenience
  • handle the case where the (one of the) latest fetch blocks (cf. Tenderbake finality) should be reverted because another one has been finalized

This part is what is called an (a blockchain) indexer. Then you should expose the content of your database via an API server.

Non-technical answer/question:

Why do want to do this? There are already indexers and block explorers on/for Tezos.

11
  • I want to show the last processed block on my website. I know it is already exists in TzStats. Sep 19 at 4:12
  • I have a confusion. I am running the node using command line "./tezos-node run". I can see the blocks here but how to fetch data from here using RPC /chains/main/blocks/<head|block_hash>. Please let me know. Sep 19 at 4:14
  • @MuhtasimFahim You send a HTTP GET request (or POST for other endpoints) to the full URL pointing to your server, with /chains/main/blocks/<head|block_hash> being the endpoint. E.g. http://mydomain.com/chains/main/blocks/<head|block_hash> or maybe an IP address / port number
    – Simon McLoughlin
    Sep 19 at 8:03
  • I need to fetch the processed blocks automatically and store the data of those blocks into database and show only the last processed block information. Can you please give me any resource or tutorials how to go with it? It would be helpful and the API is also not working in my local device. Sep 19 at 9:29
  • I can get it by ./tezos-client rpc get /chains/<chain_id>/blocks/<block_id>. How can I make the block_id or hash dynamic? Sep 19 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.