- Notifications
You must be signed in to change notification settings - Fork1k
Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
License
Apache-2.0, MIT licenses found
Licenses found
graphprotocol/graph-node
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The Graph is a decentralized protocol that organizes and distributes blockchain data across the leading Web3 networks. A key component of The Graph's tech stack is Graph Node.
Before usinggraph-node,
it is highly recommended that you read theofficial Graph documentation to understand Subgraphs, which are the central mechanism for extracting and organizing blockchain data.
This guide is for:
- Subgraph developers who want to run
graph-node
locally to test their Subgraphs during development - Contributors who want to add features or fix bugs to
graph-node
itself
For subgraph developers, it is highly recommended to use prebuilt Dockerimages to set up a localgraph-node
environment. Please readtheseinstructions to learn how to do that.
This is usually only needed for developers who want to contribute tograph-node
.
To build and run this project, you need to have the following installed on your system:
- Rust (latest stable): FollowHow to installRust. Run
rustup install stable
inthis directory to make sure all required components areinstalled. Thegraph-node
code assumes that the latest availablestable
compiler is used. - PostgreSQL:PostgreSQL Downloads listsdownloads for almost all operating systems.
- For OSX: We highly recommendPostgres.app.
- For Linux: Use the Postgres version that comes with the distribution.
- IPFS:Installing IPFS
- Protobuf Compiler:Installing Protobuf
For Ethereum network data, you can either run your own Ethereum node or use an Ethereum node provider of your choice.
Once Postgres is running, you need to issue the following commands to create a databaseand configure it for use withgraph-node
.
The name of theSUPERUSER
depends on your installation, but is usuallypostgres
or your username.
psql -U<SUPERUSER><<EOFcreate user graph with password '<password>';create database "graph-node" with owner=graph template=template0 encoding='UTF8' locale='C';create extension pg_trgm;create extension btree_gist;create extension postgres_fdw;grant usage on foreign data wrapper postgres_fdw to graph;EOF
For convenience, set the connection string to the database in an environmentvariable, and save it, e.g., in~/.bashrc
:
export POSTGRES_URL=postgresql://graph:<password>@localhost:5432/graph-node
Use thePOSTGRES_URL
from above to havegraph-node
connect to thedatabase. If you ever need to manually inspect the contents of yourdatabase, you can do that by runningpsql $POSTGRES_URL
. Running thiscommand is also a convenient way to check that the database is up andrunning and that the connection string is correct.
Clone this repository and run this command at the root of the repository:
export GRAPH_LOG=debugcargo run -p graph-node --release -- \ --postgres-url$POSTGRES_URL \ --ethereum-rpc NETWORK_NAME:[CAPABILITIES]:URL \ --ipfs 127.0.0.1:5001
The argument for--ethereum-rpc
contains a network name (e.g.mainnet
) anda list of provider capabilities (e.g.archive,traces
). The URL is the addressof the Ethereum node you want to connect to, usually ahttps
URL, so that theentire argument might bemainnet:archive,traces:https://provider.io/some/path
.
Whengraph-node
starts, it prints the various ports that it is listening on.The most important of these is the GraphQL HTTP server, which by defaultis athttp://localhost:8000
. You can use routes like/subgraphs/name/<subgraph-name>
and/subgraphs/id/<IPFS hash>
to query subgraphs once you have deployed them.
Follow theSubgraph deploymentguide.After setting upgraph-cli
as described, you can deploy a Subgraph to yourlocal Graph Node instance.
The command line arguments generally are all that is needed to run agraph-node
instance. For advanced uses, various aspects ofgraph-node
can further be configured throughenvironmentvariables.
Very largegraph-node
instances can also be configured using aconfiguration file That is usually only necessary whenthegraph-node
needs to connect to multiple chains or if the work ofindexing and querying needs to be split acrossmultiple databases.
Please checkCONTRIBUTING.md for development flow and conventions we use.Here'sa list of good first issues.
Copyright © 2018-2019 Graph Protocol, Inc. and contributors.
The Graph is dual-licensed under theMIT license and theApache 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.
About
Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
Topics
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.