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.
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 initalizes 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 <<EOFcreate 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/.
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.
请发表评论