• Stars
    star
    2,882
  • Rank 15,744 (Top 0.4 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL

Graph Node

Build Status Getting Started Docs

The Graph is a protocol for building decentralized applications (dApps) quickly on Ethereum and IPFS using GraphQL.

Graph Node is an open source Rust implementation that event sources the Ethereum blockchain to deterministically update a data store that can be queried via the GraphQL endpoint.

For detailed instructions and more context, check out the Getting Started Guide.

Quick Start

Prerequisites

To build and run this project you need to have the following installed on your system:

For Ethereum network data, you can either run your own Ethereum node or use an Ethereum node provider of your choice.

Minimum Hardware Requirements:

  • To build graph-node with cargo, 8GB RAM are required.

Running a Local Graph Node

This is a quick example to show a working Graph Node. It is a subgraph for Gravatars.

  1. Install IPFS and run ipfs init followed by ipfs daemon.
  2. Install PostgreSQL and run initdb -D .postgres followed by pg_ctl -D .postgres -l logfile start and createdb graph-node.
  3. If using Ubuntu, you may need to install additional packages:
    • sudo apt-get install -y clang libpq-dev libssl-dev pkg-config
  4. In the terminal, clone https://github.com/graphprotocol/example-subgraph, and install dependencies and generate types for contract ABIs:
yarn
yarn codegen
  1. In the terminal, clone https://github.com/graphprotocol/graph-node, and run cargo build.

Once you have all the dependencies set up, you can run the following:

cargo run -p graph-node --release -- \
  --postgres-url postgresql://USERNAME[:PASSWORD]@localhost:5432/graph-node \
  --ethereum-rpc NETWORK_NAME:[CAPABILITIES]:URL \
  --ipfs 127.0.0.1:5001

Try your OS username as USERNAME and PASSWORD. For details on setting the connection string, check the Postgres documentation. graph-node uses a few Postgres extensions. If the Postgres user with which you run graph-node is a superuser, graph-node will enable these extensions when it initializes the database. If the Postgres user is not a superuser, you will need to create the extensions manually since only superusers are allowed to do that. To create them you need to connect as a superuser, which in many installations is the postgres user:

    psql -q -X -U <SUPERUSER> graph-node <<EOF
create extension pg_trgm;
create extension pg_stat_statements;
create extension btree_gist;
create extension postgres_fdw;
grant usage on foreign data wrapper postgres_fdw to <USERNAME>;
EOF

This will also spin up a GraphiQL interface at http://127.0.0.1:8000/.

  1. With this Gravatar example, to get the subgraph working locally run:
yarn create-local

Then you can deploy the subgraph:

yarn deploy-local

This will build and deploy the subgraph to the Graph Node. It should start indexing the subgraph immediately.

Command-Line Interface

USAGE:
    graph-node [FLAGS] [OPTIONS] --ethereum-ipc <NETWORK_NAME:FILE> --ethereum-rpc <NETWORK_NAME:URL> --ethereum-ws <NETWORK_NAME:URL> --ipfs <HOST:PORT> --postgres-url <URL>

FLAGS:
        --debug      Enable debug logging
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
        --admin-port <PORT>                           Port for the JSON-RPC admin server [default: 8020]
        --elasticsearch-password <PASSWORD>
            Password to use for Elasticsearch logging [env: ELASTICSEARCH_PASSWORD]

        --elasticsearch-url <URL>
            Elasticsearch service to write subgraph logs to [env: ELASTICSEARCH_URL=]

        --elasticsearch-user <USER>                   User to use for Elasticsearch logging [env: ELASTICSEARCH_USER=]
        --ethereum-ipc <NETWORK_NAME:[CAPABILITIES]:FILE>
            Ethereum network name (e.g. 'mainnet'), optional comma-seperated capabilities (eg full,archive), and an Ethereum IPC pipe, separated by a ':'

        --ethereum-polling-interval <MILLISECONDS>
            How often to poll the Ethereum node for new blocks [env: ETHEREUM_POLLING_INTERVAL=]  [default: 500]

        --ethereum-rpc <NETWORK_NAME:[CAPABILITIES]:URL>
            Ethereum network name (e.g. 'mainnet'), optional comma-seperated capabilities (eg 'full,archive'), and an Ethereum RPC URL, separated by a ':'

        --ethereum-ws <NETWORK_NAME:[CAPABILITIES]:URL>
            Ethereum network name (e.g. 'mainnet'), optional comma-seperated capabilities (eg `full,archive), and an Ethereum WebSocket URL, separated by a ':'

        --node-id <NODE_ID>
            A unique identifier for this node instance. Should have the same value between consecutive node restarts [default: default]

        --http-port <PORT>                            Port for the GraphQL HTTP server [default: 8000]
        --ipfs <HOST:PORT>                            HTTP address of an IPFS node
        --postgres-url <URL>                          Location of the Postgres database used for storing entities
        --subgraph <[NAME:]IPFS_HASH>                 Name and IPFS hash of the subgraph manifest
        --ws-port <PORT>                              Port for the GraphQL WebSocket server [default: 8001]

Advanced Configuration

The command line arguments generally are all that is needed to run a graph-node instance. For advanced uses, various aspects of graph-node can further be configured through environment variables. Very large graph-node instances can also split the work of querying and indexing across multiple databases.

Project Layout

  • node β€” A local Graph Node.
  • graph β€” A library providing traits for system components and types for common data.
  • core β€” A library providing implementations for core components, used by all nodes.
  • chain/ethereum β€” A library with components for obtaining data from Ethereum.
  • graphql β€” A GraphQL implementation with API schema generation, introspection, and more.
  • mock β€” A library providing mock implementations for all system components.
  • runtime/wasm β€” A library for running WASM data-extraction scripts.
  • server/http β€” A library providing a GraphQL server over HTTP.
  • store/postgres β€” A Postgres store with a GraphQL-friendly interface and audit logs.

Roadmap

πŸ”¨ = In Progress

πŸ›  = Feature complete. Additional testing required.

βœ… = Feature complete

Feature Status
Ethereum
Indexing smart contract events βœ…
Handle chain reorganizations βœ…
Mappings
WASM-based mappings βœ…
TypeScript-to-WASM toolchain βœ…
Autogenerated TypeScript types βœ…
GraphQL
Query entities by ID βœ…
Query entity collections βœ…
Pagination βœ…
Filtering βœ…
Block-based Filtering βœ…
Entity relationships βœ…
Subscriptions βœ…

Contributing

Please check CONTRIBUTING.md for development flow and conventions we use. Here's a list of good first issues.

License

Copyright Β© 2018-2019 Graph Protocol, Inc. and contributors.

The Graph is dual-licensed under the MIT license and the Apache License, Version 2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

graph-tooling

Monorepo for various tools used by subgraph developers.
TypeScript
387
star
2

contracts

Contracts repository for The Graph protocol
TypeScript
316
star
3

indexer

Graph Protocol indexer components and infrastructure
TypeScript
236
star
4

graph-ts

TypeScript/AssemblyScript library for writing mappings for The Graph
214
star
5

example-subgraph

An example to help you get started with The Graph
Solidity
179
star
6

graph-client

The Graph library for building GraphQL-based dapps in a decentralized way.
TypeScript
172
star
7

uniswap-subgraph

This is for uniswap-v1. If you are looking for the uniswap v2 subgraph, please go to https://github.com/uniswap/uniswap-v2-subgraph
TypeScript
105
star
8

everest

Registry of crypto projects
JavaScript
98
star
9

docs

Documentation for The Graph
MDX
78
star
10

graph-network-subgraph

The subgraph, the smart contracts, the tests, and documents for the Graph Explorer Decentralized Application
TypeScript
69
star
11

research

Research, proposals, papers, and specs
TeX
48
star
12

ipfs-sync

Script to sync files from one IPFS node to another
JavaScript
48
star
13

ethdenver-dapp

ETHDenver example dApp built on The Graph
JavaScript
43
star
14

erc20-subgraph

TypeScript
33
star
15

hardhat-graph

TypeScript
33
star
16

decentraland-subgraph

Decentraland data source for The Graph
TypeScript
29
star
17

common-ts

Common TypeScript library for use in Graph Protocol components
TypeScript
24
star
18

ens-rainbow

Rust
22
star
19

ens-subgraph

Official repo: https://github.com/ensdomains/ens-subgraph
TypeScript
22
star
20

aragon-subgraph

DAO - subgraph
TypeScript
21
star
21

mission-control-indexer

Technical indexer documentation and infrastructure templates for the Mission Control testnet
TypeScript
21
star
22

indexer-rs

Rewrite of indexer-service in Rust with TAP payments implementation
Rust
21
star
23

token-distribution

Token distribution contracts
TypeScript
21
star
24

agora

Cost model
Rust
20
star
25

rfcs

Graph Protocol RFCs and Engineering Plans
CSS
16
star
26

mission-control-curator

15
star
27

0x-subgraph

Subgraph that tracks events of the 0x protocol
TypeScript
15
star
28

example-subgraphs

TypeScript
14
star
29

allocation-optimizer

Agents and algorithms for optimizing Indexer decision problems.
Julia
14
star
30

firehose-cosmos

Cosmos Firehose integration
Go
11
star
31

support

Community support for the Hosted Service of The Graph
10
star
32

full-stack-graph-app

Deploy a full stack app leveraging The Graph with one click.
TypeScript
10
star
33

compound-v1-subgraph

Compound is an open-source protocol for algorithmic, efficient Money Markets on the Ethereum blockchain.
TypeScript
9
star
34

crypto-buddies

Gatsby React app interview challenge
JavaScript
8
star
35

augur-subgraph

Subgraph for the Augur protocol
TypeScript
8
star
36

qlog

A tool to summarize and analyze graph-node query logs
Rust
8
star
37

bitsausage

Bitsausage auction project
JavaScript
7
star
38

registry-starter

Starting point for apps that curate data
JavaScript
7
star
39

graph-network-analytics-subgraph

Analytics subgraph for Graph Network
TypeScript
6
star
40

stable-hash

A structured hash that is platform independent and has backward compatibility
Rust
6
star
41

common-subgraphs

Subgraphs that are generally useful and/or good examples
Shell
6
star
42

sportx-subgraph

SportX provides a sports betting platform for Ethereum.
TypeScript
6
star
43

block-oracle

Rust
6
star
44

graph-improvement-proposals

The canonical repository for The Graph's protocol governance. Read more about it: https://thegraph.com/ecosystem/governance/
5
star
45

FOAM-subgraph

The FOAM Proof of Location protocol empowers a permissionless and autonomous network of radio beacons that can offer secure location services.
TypeScript
5
star
46

hackathon-react-apollo-app

React, Apollo & Material UI example app
JavaScript
5
star
47

solidity-bindgen

Rust
5
star
48

hardhat-graph-demo

Demo repository for the hardhat-graph plugin
TypeScript
4
star
49

dharma-subgraph

Dharma protocol subgraph
TypeScript
4
star
50

hackathon-scaffold

A starting point for building dApps on The Graph
JavaScript
4
star
51

mutations

TypeScript
4
star
52

compound-subgraph-wrapper

A wrapper service that extends the Compound subgraph with custom resolvers
TypeScript
4
star
53

cosmoshub-ts

TypeScript
4
star
54

memefactory-subgraph

Memefactory subgraph for The Graph
TypeScript
3
star
55

eip-712-derive

Easy EIP-712
Rust
3
star
56

ipfs-mgm

IPFS cli for content syncing
Go
3
star
57

graph-node-docker

Preconfigured Docker image for running a Graph Node
Dockerfile
3
star
58

adchain-subgraph

Example subgraph project for querying the AdChain TCR
TypeScript
3
star
59

graph-local-state

Shell
2
star
60

thegarii

The Graph Arweave Integration Implementation
Rust
2
star
61

codex

2
star
62

maker-subgraph

Subgraph for maker
TypeScript
2
star
63

governance-subgraph

Subgraph for graph governance
TypeScript
2
star
64

firehose-arweave

The firehose integration with the garii
Go
2
star
65

autotasks

A collection of Defender Autotasks to interact with The Graph protocol contracts
TypeScript
2
star
66

query-examples

Provides examples of how to query Subgraphs published to The Graph Network in a variety of frameworks/languages
2
star
67

DEPRECATED-compound-v2-subgraph

Compound is an open-source protocol for algorithmic, efficient Money Markets on the Ethereum blockchain. DEPRECATED - see the repository under compound-finances github for the current repository https://github.com/graphprotocol/compound-v2-subgraph-1
TypeScript
2
star
68

everest-subgraph

Subgraph for the MetaCartel Everest project registry
1
star
69

hack-for-freedom

1
star
70

ethcc-hackathon

1
star
71

gitcoin-beyond-blockchain-hackathon

A three week virtual hackathon running from June 24th to July 10th powered by Gitcoin
1
star
72

network-support

Graph Network issues and feature requests
1
star
73

subgraph-oracle

The Subgraph Oracle
Rust
1
star
74

graph-pino

Pino log message formatter for The Graph
JavaScript
1
star