The purpose of this repository is to catch blocks on signet blockchain and provide to the client side using a rest API.
To get new blocks we are using ZeroMQ, so when the Bitcoind receive a new block/transactions a pub event happens to our node API then we catch it and store on the PostgreSQL as the flow above.
To get past blocks, at the moment when you start the server the application will go from the block 0 to the latest block on the blockchain searching for the missing blocks
Note: we can change this to do the sync every x minutes
Note: now we are syncing the blocks and transactions together, but going by the block, on the future maybe access each block and search for the missing transactions
- A computer
- Node 16
- Bitcoin-cli with bitcoind
- Clone the project on your machine.
- Download docker and docker-compose on your machine here.
- Run
docker-compose up -d
on the root. - Setup the Environment variables for Postgres(You can use the same on the .env.example docker is waiting for these ones)
- Download bitcoin-core
- Setup your
bitcoin.conf
file to use signet and ZeroMQ emit sockets totcp://127.0.0.1:3600
, you can copy on./examples/bitcoin.conf
, or follow How to setup bitcoin.conf file - Setup the Environment Variable(.env), if you follow the example of
bitcoin.conf
on examples folder you can use the.env.example
file on your.env
- Run the node on your terminal using
bitcoind -signet -daemon
.
Don't forget to setup the environment variables, as they are necessary to connect to the database and it is the way the application has access to rpc as well.
After do the steps above and had installed the packages only run the command below, that the API, subscription and sync will happen automatically:
yarn dev
To get the blocks you can go on your browser or Postman/Insomnia and use the endpoint to get all the transactions/blocks related to your OP_RETURN.
Method: GET
Endpoint: http://localhost:3000/opreturn/:opreturn
- Add tests for the RPC, endpoints, and sequelize.
- Create a syncronization second for the transactions maybe, now we are getting the transactions together with the blocks
- Improve observability adding more logs, Sentry, APM.
- Improve documentation, a good idea can be add Docusaurus or Swagger.
- Improve the queries, add indexes to have fast inserts, replicate-set for read operations
- Search alternatives for bitcoind-rpc it's deprecated.