Code Monkey home page Code Monkey logo

chaingraph's Introduction

CI Codecov Follow Chaingraph on Twitter Join Chat on Telegram Docker Pulls GitHub stars

Chaingraph

A multi-node blockchain indexer and GraphQL API.

For more information, and for examples of live subscriptions and complex queries, see chaingraph.cash.

chaingraph-demo-video

Quick Start

Chaingraph runs on Kubernetes, making it easy to deploy for production usage across many cloud providers or on self-managed hardware.

This guide describes a simple testnet deployment to a production Kubernetes cluster.

To deploy Chaingraph locally, see the instructions in the Contributing Guide. For details about other configurations, see the chart documentation.

Create a Cluster

As of late 2021, DigitalOcean is the most cost-effective cloud provider for Chaingraph deployments (differentiated primarily by pricing of egress bandwidth and persistent volume SSD storage).

To set up a new cluster, consider using Chaingraph's referral code for a $100 credit (supports demo.chaingraph.cash); this should cover a production-ready BCH mainnet deployment for ~30 days (approximately $85/month for SSD storage, one $10/month droplet, and $10/month for the load balancer and egress bandwidth).

Whichever cloud provider you choose, for the below testnet deployment, provision at least 1 Kubernetes node of the least expensive type.

Typically, providers offer setup commands which add cluster authentication information to your local kubectl settings. Once your cluster is created, follow the provider's instructions for connecting to the cluster from your machine.

Add the Chart Repo

To deploy Chaingraph to your cluster, first install Helm, then add the bitauth repo:

helm repo add bitauth https://charts.bitauth.com/

If you have previously added the bitauth repo, run helm repo update to fetch the latest charts.

Deploy a Release

Using the default configuration, Chaingraph will be installed with a single testnet4 BCHN full node, an internally-managed Postgres instance, and no load balancer.

This is an ideal configuration for experimenting with Chaingraph, as it can be deployed on very low-powered clusters (often even within the free tier provided by many cloud Kubernetes providers). See the chart readme for information about other options.

helm install my-chaingraph bitauth/chaingraph

Review the notes which are logged after installation for more information about your deployment. You'll find an API section with instructions for exposing Chaingraph's GraphQL API.

Once the API is public, you're ready to start using Chaingraph. We recommend graphqurl for exploring the API. Use -i to open the interactive GraphiQL UI:

npm install -g graphqurl
gq -i http://YOUR_IP:PORT/v1/graphql

Chaingraph's API is available during the initial sync. Try monitoring it with a subscription:

subscription MonitorSyncTips {
  node {
    name
    user_agent
    latest_tip: accepted_blocks(
      limit: 1
      order_by: { block_internal_id: desc }
    ) {
      block {
        hash
        height
        transaction_count
        size_bytes
      }
    }
  }
}
More details

This subscription returns the list of nodes connected to Chaingraph, their version information, and the hash, height, size, and transaction count of the most recently saved block accepted by that node.

Note, Chaingraph saves blocks asynchronously, and large blocks can take longer to save to the database. During initial sync, this may cause the subscription to occasionally update its result with lower-height (more recently saved) blocks. Regardless, this subscription will roughly track sync progress for each connected node.

This query could also be ordered by block height, but because non-primary indexes are created after initial sync (to reduce time required), ordering by block height can be slow until after the initial sync is complete.

Mainnet Chaingraph deployments may take 10 hours or more to sync fully and build all indexes (depending primarily on the performance of configured nodes and the write speed of the database volume). Testnet deployments typically finish in a few minutes.

To continue exploring the Chaingraph API, check out the example queries on chaingraph.cash.

Architecture

Chaingraph is a Kubernetes application which manages a stack of open source software including one or more Bitcoin Cash full nodes, a syncing agent, a Postgres SQL database, and a Hasura instance.

Learn more about Chaingraph's Architecture โ†’

Schema

While many indexers are designed to support only one node implementation, Chaingraph is designed from the ground up to support multiple nodes.

Rather than assuming a single-node source-of-truth view of the network, the Chaingraph database schema and GraphQL API differentiate which nodes have acknowledged any particular transaction or block, and a full timeline is maintained for transaction validation, block acceptance, observed double-spends, and block re-organizations.

This additional information makes it possible for businesses to handle unusual network behavior without manual intervention by employing defensive consensus strategies.

Learn more about Chaingraph's API Schema โ†’

Contributing

To set up a local cluster for development, please see the Contributing Guide.

chaingraph's People

Contributors

bitjson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.