liftedinit / yaci

Yet Another Cosmos Indexer
Apache License 2.0
6 stars 3 forks source link

yaci

build coverage Go Report Card

yaci is a command-line tool that connects to a gRPC server and extracts blockchain data.

Tested with Cosmos SDK v0.50.x.

Use-case

Off-chain indexing of block & transaction data.

Requirements

Features

Installation

To install the yaci tool, you need to have Go installed on your system. Then, you can use the following command to install yaci:

go install github.com/liftedinit/yaci@latest

The yaci binary will be installed in the $GOPATH/bin directory.

Usage

The basic usage of the yaci tool is as follows:

yaci [command] [address] [flags]

Commands

Global Flags

Extract Command

Extract blockchain data and output it in the specified format.

Flags

The following flags are available for all extract subcommand:

Subcommands

PostgreSQL Subcommand

Extract blockchain data and output it to a PostgreSQL database.

Usage

Usage:
  yaci extract postgres [address] [flags]

Flags

Example

yaci extract postgres localhost:9090 -p postgres://postgres:foobar@localhost/postgres -s 106000 -k --live -t 5

This command will connect to the gRPC server running on localhost:9090, continuously extract data from block height 106000 and store the extracted data in the postgres database. New blocks and transactions will be inserted into the database every 5 seconds.

Configuration

The yaci tool parameters can be configured from the following sources

The command-line flags have the highest priority, followed by the environment variables, and then the configuration file.

The environment variables are prefixed with YACI_ and are in uppercase. For example, the --logLevel flag can be set using the YACI_LOGLEVEL environment variable. Dash (-) is replaced with underscore (_). For example, the --block-time flag can be set using the YACI_BLOCK_TIME environment variable.

The configuration file is searched in the following order:

Demo

To run the demo, you need to have Docker installed on your system. Then, you can run the following command:

# Build and start the e2e environment
make docker-up

Wait for the e2e environment to start. Then, open a new browser tab and navigate to http://localhost:3000/blocks?order=id.desc to view the blocks and to http://localhost:3000/transactions to view the transactions.

Run

make docker-down

to stop the e2e environment.

Testing

To run the unit tests, you can use the following command:

make test

To run the end-to-end tests, you can use the following command:

make test-e2e

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.