Skip to content

Blockchain Indexer or Data Cacher for specific a chosen smart contract

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING
LGPL-3.0
COPYING.LESSER
Notifications You must be signed in to change notification settings

0x365/blockchain-indexer

SpaceDAO Indexer

Dev README

About the project

This indexer listens for all events executed on a specific smart contract and puts them in a MySQL Database. It is meant to be easy to use (after its completed). This is then meant to be used to interact with quickly for web applications rather than the slower blockchain. All details in the database can be checked against the blockchain at any point to ensure security. DAO stands for Decentralized Autonomous Organization. And is meant to support Autonomous Orbit Applications and Services. Space exploration and usage is decentralized by Nature, centralizing it would only bring global tensions. SpaceDAO is a technological approach with conscious geo-political concerns. It kick started thanks to the Open Space Innovation Platform of the European Space Agency (ESA) as part of the campaign for Cognitive Cloud Computing. The executive summary of the study is publicly visible on ESA's projects listing (called Nebula). The Indexer is an open source artifact under the LGPL-v-3-0 license.

IndexerArchitecture

Built with

These projects are used to build the indexer:

  • Ethers.js for connecting to the EVM blockchains
  • MariaDB for storing smart contract event data in a database
  • MySQL2.js for connecting to the MariaDB database
  • Express for creating the API that exposes the data in the MariaDB database
  • Docker for containerising the project and making it easy to startup

Usage

Prerequisites

  • Docker Compose sudo apt install docker-compose
  • You will require a blockchain node api service. I recommend Infura
  • Currently designed for ubuntu (however it might work on windows)

Setup target contract and events

  1. Create .env file. The database details do not neccessarily need changed however you need to add the blockchain node api urls. Copy the example .env file with:
cp .env-example .env
  1. Adapt target.json based on the contract details, deployed network and event names that you desire to index. An example is given below and with the full abi in target.json. More examples are given in /example_targets/. /example_targets/target_big.json is a contract that has a large amount of calls per second on the mainnet, and /example_targets/target_small.json is has a single event call.
{
  "network": "sepolia",
  "address": "0xFF1aae6928D49c3744a81F891621e848914898ed",
  "deploy_block": 7354710,
  "contract_events": ["ContractCreated"],
  "abi": [...]
}

Install npm packages

This will install all required npm packages in /node_modules/. The versions of the packages can be seen in package.json

npm install

Start Indexer

Running up will start indexer, while running down will make sure it is fully stopped.

sudo docker-compose up
sudo docker-compose down

Reset Indexer

Make sure the sudo docker-compose down has been run to fully stop the indexer. Running ls will show the VOLUME_NAME for the the rm command to remove all contents of the database.

sudo docker volume ls
sudo docker volume rm VOLUME_NAME

Licensing

This work is licensed under the GNU LESSER GENERAL PUBLIC LICENSE version 3 and above. All contributors accepts terms of this license. See LICENSE for more information.

About

Blockchain Indexer or Data Cacher for specific a chosen smart contract

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING
LGPL-3.0
COPYING.LESSER

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published