---
# System prepended metadata

title: Subgraph on local graph node with firehose for Persistence chain

---

# Subgraph on local graph node with firehose for Persistence chain

## Persistence Core binary
Changes made in `go.mod` file as can be seen in this [diff](https://github.com/persistenceOne/persistenceCore/commit/2f8a2a3514c6e6105fae2dbe60500953617287dd#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6). 
```bash=
git clone https://github.com/nabaruns/persistenceCore.git
cd persistenceCore
git checkout firehose-v3.1.0
go mod download
make all
```

## Firehose-cosmos
Check [Syncing docs](https://firehose.streamingfast.io/operate/guides/cosmos/syncing/) for more details. 
> This fork has added some config to the `bootstrap.sh` for
> - Testnet `test-core-1`, or 
> - Localnet: launch a new localnet with a single validator and 2 users.
### Install

```bash=
git clone https://github.com/nabaruns/firehose-cosmos.git
cd firehose-cosmos
git checkout persistence
make install
```
### Bootstrap `persistenceCore` and `firehose`
Make changes in `devel/persistence/bootstrap.sh` files to run firehose for localnet or testnet.
```bash=
NETWORK=${NETWORK:-"localnet"}
```
When using on testnet, since state-sync mode is enabled, this height is required to be in current 100 block range of recent block height.
```bash=
PERSISTENCE_GENESIS_HEIGHT=${PERSISTENCE_GENESIS_HEIGHT:-"7232900"}
```
Check recent height
```bash=
curl -s https://rpc.testnet.persistence.one/status | jq '.result .sync_info | {latest_block_height: .latest_block_height, latest_block_hash: .latest_block_hash} | values'
```
~~~md
{
  "latest_block_height": "7308029",
  "latest_block_hash": "D9AF99894F4B3F535679EC759F54F30208C7219842FA86A86640050C05C44B53"
}
~~~
> So, we can set `PERSISTENCE_GENESIS_HEIGHT` config as 7308000. For localnet, this is to be set as 1.

If running for first time to use localnet, please comment out keys delete line:
```bash=
    echo "y" | $persistenceCore_PATH --home persistenceCore_home keys delete validator --keyring-backend test
    echo "y" | $persistenceCore_PATH --home persistenceCore_home keys delete user1 --keyring-backend test
    echo "y" | $persistenceCore_PATH --home persistenceCore_home keys delete user2 --keyring-backend test
```

And then run
```bash=
./devel/persistence/bootstrap.sh
```
Following output can be seen for `localnet` use case.
~~~md
Using LOCALNET
Setting up working directory
~/IdeaProjects/work/subgraph/firehose-cosmos/devel/persistence/tmp ~/IdeaProjects/work/subgraph/firehose-cosmos/devel/persistence
Your platform is Darwin/arm64
Configuring home directory
Adding genesis accounts...
Key deleted forever (uh oh!)
Key deleted forever (uh oh!)
Key deleted forever (uh oh!)

- name: validator
  type: local
  address: persistence1074vppsz6na2ur40psw2y4zx0up59vz2es25ya
  pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/LBk1dthcJcae72ZaTPEGDrGa80ZsvJQ4SF5cpswXPB"}'
  mnemonic: ""


- name: user1
  type: local
  address: persistence1m9lfg6fav7jev6mtzua0k589nhrytuwl6f96js
  pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Als4EmbNgKZP8pf1aKgMGWW4Bqk4dMOaKjo24qIUqL3z"}'
  mnemonic: ""


- name: user2
  type: local
  address: persistence1d5sqrj65ju7t4cq7mkxrluv46rvplj7qaaac3l
  pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A8/zI5p82VQdOBZoLMngihqZrTtrfQbQAr55XMJ8CU+O"}'
  mnemonic: ""

Creating and collecting gentx...
Genesis transaction written to "persistenceCore_home/config/gentx/gentx-f2d8ba3545c74b7d4a85ae501d6f196212bef99c.json"
{"app_message":{"auth":{"accounts":[{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"0","address":"persistence1074vppsz6na2ur40psw2y4zx0up59vz2es25ya","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"0","address":"persistence1m9lfg6fav7jev6mtzua0k589nhrytuwl6f96js","pub_key":null,"sequence":"0"},{"@type":"/cosmos.auth.v1beta1.BaseAccount","account_number":"0","address":"persistence1d5sqrj65ju7t4cq7mkxrluv46rvplj7qaaac3l","pub_key":null,"sequence":"0"}],"params":{"max_memo_characters":"256","sig_verify_cost_ed25519":"590","sig_verify_cost_secp256k1":"1000","tx_sig_limit":"7","tx_size_cost_per_byte":"10"}},"authz":{"authorization":[]},"bank":{"balances":[{"address":"persistence1d5sqrj65ju7t4cq7mkxrluv46rvplj7qaaac3l","coins":[{"amount":"1000000000000000","denom":"stake"}]},{"address":"persistence1074vppsz6na2ur40psw2y4zx0up59vz2es25ya","coins":[{"amount":"1000000000000000","denom":"stake"}]},{"address":"persistence1m9lfg6fav7jev6mtzua0k589nhrytuwl6f96js","coins":[{"amount":"1000000000000000","denom":"stake"}]}],"denom_metadata":[],"params":{"default_send_enabled":true,"send_enabled":[]},"supply":[{"amount":"3000000000000000","denom":"stake"}]},"capability":{"index":"1","owners":[]},"crisis":{"constant_fee":{"amount":"1000","denom":"stake"}},"distribution":{"delegator_starting_infos":[],"delegator_withdraw_infos":[],"fee_pool":{"community_pool":[]},"outstanding_rewards":[],"params":{"base_proposer_reward":"0.010000000000000000","bonus_proposer_reward":"0.040000000000000000","community_tax":"0.020000000000000000","withdraw_addr_enabled":true},"previous_proposer":"","validator_accumulated_commissions":[],"validator_current_rewards":[],"validator_historical_rewards":[],"validator_slash_events":[]},"evidence":{"evidence":[]},"feegrant":{"allowances":[]},"genutil":{"gen_txs":[{"auth_info":{"fee":{"amount":[],"gas_limit":"200000","granter":"","payer":""},"signer_infos":[{"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A/LBk1dthcJcae72ZaTPEGDrGa80ZsvJQ4SF5cpswXPB"},"sequence":"0"}]},"body":{"extension_options":[],"memo":"f2d8ba3545c74b7d4a85ae501d6f196212bef99c@192.168.20.123:26656","messages":[{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","commission":{"max_change_rate":"0.010000000000000000","max_rate":"0.200000000000000000","rate":"0.100000000000000000"},"delegator_address":"persistence1074vppsz6na2ur40psw2y4zx0up59vz2es25ya","description":{"details":"","identity":"","moniker":"Nabaruns-MacBook-Pro.local","security_contact":"","website":""},"min_self_delegation":"1","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"p6tKHQtDzgAQMvLOx7v2oN8SEjCL94ULChaltwqJwCQ="},"validator_address":"persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy","value":{"amount":"1000000000","denom":"stake"}}],"non_critical_extension_options":[],"timeout_height":"0"},"signatures":["IE7DjytomlgPpG7SGLwVf5gx1PEzZ7I/Yv4y8aYmMstxzDL1Ex5kN9s4c6uEsUy0Xd4FI73RBlmOOtVPtkIJ9w=="]}]},"gov":{"deposit_params":{"max_deposit_period":"172800s","min_deposit":[{"amount":"10000000","denom":"stake"}]},"deposits":[],"proposals":[],"starting_proposal_id":"1","tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"votes":[],"voting_params":{"voting_period":"172800s"}},"halving":{"params":{"blockHeight":"12623040"}},"ibc":{"channel_genesis":{"ack_sequences":[],"acknowledgements":[],"channels":[],"commitments":[],"next_channel_sequence":"0","receipts":[],"recv_sequences":[],"send_sequences":[]},"client_genesis":{"clients":[],"clients_consensus":[],"clients_metadata":[],"create_localhost":false,"next_client_sequence":"0","params":{"allowed_clients":["06-solomachine","07-tendermint"]}},"connection_genesis":{"client_connection_paths":[],"connections":[],"next_connection_sequence":"0","params":{"max_expected_time_per_block":"30000000000"}}},"interchainaccounts":{"controller_genesis_state":{"active_channels":[],"interchain_accounts":[],"params":{"controller_enabled":true},"ports":[]},"host_genesis_state":{"active_channels":[],"interchain_accounts":[],"params":{"allow_messages":[],"host_enabled":true},"port":"icahost"}},"mint":{"minter":{"annual_provisions":"0.000000000000000000","inflation":"0.130000000000000000"},"params":{"blocks_per_year":"6311520","goal_bonded":"0.670000000000000000","inflation_max":"0.200000000000000000","inflation_min":"0.070000000000000000","inflation_rate_change":"0.130000000000000000","mint_denom":"stake"}},"params":null,"slashing":{"missed_blocks":[],"params":{"downtime_jail_duration":"600s","min_signed_per_window":"0.500000000000000000","signed_blocks_window":"100","slash_fraction_double_sign":"0.050000000000000000","slash_fraction_downtime":"0.010000000000000000"},"signing_infos":[]},"staking":{"delegations":[],"exported":false,"last_total_power":"0","last_validator_powers":[],"params":{"bond_denom":"stake","historical_entries":10000,"max_entries":7,"max_validators":100,"unbonding_time":"1814400s"},"redelegations":[],"unbonding_delegations":[],"validators":[]},"transfer":{"denom_traces":[],"params":{"receive_enabled":true,"send_enabled":true},"port_id":"transfer"},"upgrade":{},"vesting":{},"wasm":{"codes":[],"contracts":[],"gen_msgs":[],"params":{"code_upload_access":{"address":"","permission":"Everybody"},"instantiate_default_permission":"Everybody"},"sequences":[]}},"chain_id":"localnet","gentxs_dir":"persistenceCore_home/config/gentx","moniker":"Nabaruns-MacBook-Pro.local","node_id":"f2d8ba3545c74b7d4a85ae501d6f196212bef99c"}
~~~

### Start `firehose`
> If running for `localnet`, this will also start a `persistenceCore` localnet.
```bash=
./devel/cosmoshub4/start.sh
```

### Check streaming blocks with:
> If running for first time after bootstrapping, it would take sometime until the firehose is live; wait upto 100 blocks in case of localnet
```bash=
grpcurl -plaintext localhost:9030 sf.firehose.v1.Stream.Blocks | jq
```

## Graph-Node setup
For reference, check [Running a Local Graph Node](https://github.com/graphprotocol/graph-node#running-a-local-graph-node).

## Postgres

### Install

```bash=
brew install postgresql
brew start service postgresql
```

### Createdb

```bash=
createdb graph-node
```

### Dropdb

only when necessary

```
psql -U nabarunsarkar -d postgres
DROP DATABASE graph-node;
\q
```

## IPFS

### Install
after installing ipfs
```bash=
ipfs init
```

### Start
```bash=
ipfs daemon
```
~~~md
Initializing daemon...
go-ipfs version: 0.13.1
Repo version: 12
System version: arm64/darwin
Golang version: go1.18.3
Swarm listening on /ip4/10.128.10.28/tcp/4001
Swarm listening on /ip4/10.128.10.28/udp/4001/quic
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/127.0.0.1/udp/4001/quic
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /ip6/::1/udp/4001/quic
Swarm listening on /p2p-circuit
Swarm announcing /ip4/10.128.10.28/tcp/4001
Swarm announcing /ip4/10.128.10.28/udp/4001/quic
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/127.0.0.1/udp/4001/quic
Swarm announcing /ip4/5.32.126.2/tcp/4001
Swarm announcing /ip4/5.32.126.2/udp/4001/quic
Swarm announcing /ip6/::1/tcp/4001
Swarm announcing /ip6/::1/udp/4001/quic
API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
~~~

## Rust

### Install
Make sure Rust is installed. Check [here](https://www.rust-lang.org/tools/install).

## Start Graph-Node

### Install

```bash=
git clone https://github.com/nabaruns/graph-node.git
cd graph-node
git checkout persistence-config
```

### Config
Edit `config.toml` and make changes as following for `localnet`, else use same config for `testnet`.
```bash=
[deployment]
[[deployment.rule]]
shard = "primary"
indexers = [ "index_node_cosmos_1" ]

[store]
[store.primary]
connection = "postgresql://nabarunsarkar:[PASSWORD]@localhost:5432/graph-node"
pool_size = 10

[chains]
ingestor = "block_ingestor_node"

[chains.localnet]
shard = "primary"
protocol = "cosmos"
provider = [
  { label = "localnet", details = { type = "firehose", url = "http://0.0.0.0:9030/" }},
]
```

### Start graph-node

```bash=
cargo +nightly run -p graph-node --release -- \
 --config config.toml \
 --ipfs 127.0.0.1:5001 \
 --node-id index_node_cosmos_1
```
~~~md
     Running `target/release/graph-node --config config.toml --ipfs '127.0.0.1:5001' --node-id index_node_cosmos_1`
Jul 21 12:40:10.500 INFO Graph Node version: 0.26.0 :: hosted-current+106 (a66caafe0 2022-07-12) dirty 3 modifications
Jul 21 12:40:10.501 WARN GRAPH_POI_ACCESS_TOKEN not set; might leak POIs to the public via GraphQL
Jul 21 12:40:10.501 INFO Reading configuration file `config.toml`
Jul 21 12:40:10.502 WARN No fork base URL specified, subgraph forking is disabled
Jul 21 12:40:10.502 INFO Starting up
Jul 21 12:40:10.502 INFO Trying IPFS node at: http://127.0.0.1:5001/
Jul 21 12:40:10.504 INFO Creating firehose endpoint, url: http://0.0.0.0:9030/, provider: localnet
Jul 21 12:40:10.505 INFO Successfully connected to IPFS node at: http://127.0.0.1:5001/
Jul 21 12:40:10.558 INFO Connecting to Postgres, weight: 1, conn_pool_size: 10, url: postgresql://nabarunsarkar:HIDDEN_PASSWORD@localhost:5432/graph-node, pool: main, shard: primary
Jul 21 12:40:10.558 INFO Pool successfully connected to Postgres, pool: main, shard: primary, component: Store
Jul 21 12:40:10.606 INFO Setting up fdw, pool: main, shard: primary, component: ConnectionPool
Jul 21 12:40:10.633 INFO Running migrations, pool: main, shard: primary, component: ConnectionPool
Jul 21 12:40:10.900 INFO Migrations finished, pool: main, shard: primary, component: ConnectionPool
Jul 21 12:40:10.902 INFO Mapping primary, pool: main, shard: primary, component: ConnectionPool
Jul 21 12:40:10.947 INFO Connecting to Firehose to get chain identifier, url: http://0.0.0.0:9030/, provider: localnet
Jul 21 12:40:10.947 INFO Requesting genesis block from firehose, provider: localnet
Jul 21 12:40:10.955 INFO Connected to Firehose, genesis_block: #1 (9090703dce907d57b2915d29077962652cdfd445c6286e48d2838155392b5c7d), uri: http://0.0.0.0:9030/, provider: localnet
Jul 21 12:40:11.451 INFO Creating LoadManager in disabled mode, component: LoadManager
Jul 21 12:40:11.451 INFO Starting firehose block ingestors with 0 chains []
Jul 21 12:40:11.451 INFO Starting firehose block ingestors with 0 chains []
Jul 21 12:40:11.451 INFO Starting firehose block ingestors with 1 chains [localnet]
Jul 21 12:40:11.451 INFO Starting firehose block ingestor for network, network_name: localnet
Jul 21 12:40:11.455 INFO Starting job runner with 4 jobs, component: JobRunner
Jul 21 12:40:11.457 INFO Starting JSON-RPC admin server at: http://localhost:8020, component: JsonRpcServer
Jul 21 12:40:11.458 INFO Starting GraphQL HTTP server at: http://localhost:8000, component: GraphQLServer
Jul 21 12:40:11.458 INFO Starting index node server at: http://localhost:8030, component: IndexNodeServer
Jul 21 12:40:11.458 INFO Starting metrics server at: http://localhost:8040, component: MetricsServer
Jul 21 12:40:11.458 INFO Starting GraphQL WebSocket server at: ws://localhost:8001, component: SubscriptionServer
Jul 21 12:40:11.458 INFO Blockstream disconnected, connecting, cursor: , endpoint uri: http://0.0.0.0:9030/, provider: localnet, component: FirehoseBlockIngestor
Jul 21 12:40:11.459 INFO Started all assigned subgraphs, node_id: index_node_cosmos_1, count: 0, component: SubgraphRegistrar
~~~

## Subgraph example

### Clone

```bash=
git clone https://github.com/nabaruns/example-subgraph.git
cd example-subgraph && git checkout persistence-validator-rewards
```
For using on localnet, `config/persistence.json` is modified as
```json
-  "network": "test-core-1"
+  "network": "localnet"
```
### Prepare and generate schema

```
yarn install && yarn prepare:persistence
yarn codegen && yarn build
```
~~~md
yarn install v1.22.19
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
✨  Done in 2.25s.

yarn run v1.22.19
$ mustache config/persistence.json subgraph.template.yaml > subgraph.yaml
✨  Done in 0.75s.

yarn run v1.22.19
$ graph codegen
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
  Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
  Skip migration: Bump mapping apiVersion from 0.0.6 to 0.0.7
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
  Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
  Skip migration: Bump manifest specVersion from 0.0.4 to 0.0.5
✔ Apply migrations
⚠ Warnings while loading subgraph from subgraph.yaml: Warnings in subgraph.yaml:

    Path: repository
    The repository is still set to https://github.com/graphprotocol/example-subgraph.
    Please replace it with a link to your subgraph source code.

✔ Load subgraph from subgraph.yaml
✔ Generate types for data source templates
✔ Load GraphQL schema from schema.graphql
  Write types to generated/schema.ts
✔ Generate types for GraphQL schema

Types generated successfully

✨  Done in 1.55s.

yarn run v1.22.19
$ graph build
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
  Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
  Skip migration: Bump mapping apiVersion from 0.0.6 to 0.0.7
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
  Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
  Skip migration: Bump manifest specVersion from 0.0.4 to 0.0.5
✔ Apply migrations
⚠ Warnings loading subgraph from subgraph.yaml: Warnings in subgraph.yaml:

    Path: repository
    The repository is still set to https://github.com/graphprotocol/example-subgraph.
    Please replace it with a link to your subgraph source code.

✔ Load subgraph from subgraph.yaml
  Compile data source: CosmosHub => build/CosmosHub/CosmosHub.wasm
✔ Compile subgraph
  Copy schema file build/schema.graphql
  Write subgraph manifest build/subgraph.yaml
✔ Write compiled subgraph to build/

Build completed: /Users/nabarunsarkar/IdeaProjects/work/subgraph/example-subgraph/build/subgraph.yaml

✨  Done in 3.68s.
~~~

### Deploy

```
yarn create-local && yarn deploy-local
```
~~~md
yarn run v1.22.19
$ graph create cosmos-validator-rewards --node http://0.0.0.0:8020
Created subgraph: cosmos-validator-rewards

yarn run v1.22.19
$ graph deploy cosmos-validator-rewards -l v0.1.0 --ipfs http://0.0.0.0:5001 --node http://0.0.0.0:8020
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
  Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
  Skip migration: Bump mapping apiVersion from 0.0.6 to 0.0.7
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
  Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
  Skip migration: Bump manifest specVersion from 0.0.4 to 0.0.5
✔ Apply migrations
⚠ Warnings loading subgraph from subgraph.yaml: Warnings in subgraph.yaml:

    Path: repository
    The repository is still set to https://github.com/graphprotocol/example-subgraph.
    Please replace it with a link to your subgraph source code.

✔ Load subgraph from subgraph.yaml
  Compile data source: Persistence => build/Persistence/Persistence.wasm
✔ Compile subgraph
  Copy schema file build/schema.graphql
  Write subgraph manifest build/subgraph.yaml
✔ Write compiled subgraph to build/
  Add file to IPFS build/schema.graphql
                .. QmYhYJM19TF5pdNAyai7VyVhAR86YYyU6nKDsxMiiVkqcq
  Add file to IPFS build/Persistence/Persistence.wasm
                .. QmWsjFGfho3ZHNu1Y2xSFvkH933AFH2z5n1a45LfGnZKNJ
✔ Upload subgraph to IPFS

Build completed: QmTERe573jKf7w2cMWtDnr4LSsCHrURxTacAZDqkzrSqdb

Deployed to http://0.0.0.0:8000/subgraphs/name/cosmos-validator-rewards/graphqlSubgraph endpoints:

Queries (HTTP):     http://0.0.0.0:8000/subgraphs/name/cosmos-validator-rewards

✨  Done in 3.28s.
~~~

On terminal with graph-node running, we can see following:
~~~md
Jul 21 12:41:13.743 INFO Received subgraph_create request, params: SubgraphCreateParams { name: SubgraphName("cosmos-validator-rewards") }, component: JsonRpcServer
Jul 21 12:41:24.110 INFO Received subgraph_deploy request, params: SubgraphDeployParams { name: SubgraphName("cosmos-validator-rewards"), ipfs_hash: DeploymentHash("QmbZi8MZ8Z2umk6aJdb17JvGHy2swyDqwTPiKkQ1FF7cn3"), node_id: None, debug_fork: None }, component: JsonRpcServer
Jul 21 12:41:24.111 INFO Resolve schema, link: /ipfs/QmYhYJM19TF5pdNAyai7VyVhAR86YYyU6nKDsxMiiVkqcq, sgd: 0, subgraph_id: QmbZi8MZ8Z2umk6aJdb17JvGHy2swyDqwTPiKkQ1FF7cn3, component: SubgraphRegistrar
~~~

### Remove

only in local env

```
yarn remove-local
```

## Graphql query
Open `http://localhost:8000` to access UI for graphql
>Access deployed subgraphs by deployment ID at /subgraphs/id/<ID> or by name at /subgraphs/name/<NAME>
    
Example: `http://localhost:8000/subgraphs/id/QmbZi8MZ8Z2umk6aJdb17JvGHy2swyDqwTPiKkQ1FF7cn3/graphql`
    
### Query
```bash
query {
  rewards{
    validator,
    amount,
    id
  }
}
```
~~~md
{
  "data": {
    "rewards": [
      {
        "validator": "persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy",
        "amount": "19155478.770000000000000000stake",
        "id": "10-persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy"
      },
      {
        "validator": "persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy",
        "amount": "19155787.530000000000000000stake",
        "id": "100-persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy"
      },
      {
        "validator": "persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy",
        "amount": "19158874.200000000000000000stake",
        "id": "1000-persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy"
      },
      {
        "validator": "persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy",
        "amount": "19158877.920000000000000000stake",
        "id": "1001-persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy"
      },
      {
        "validator": "persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy",
        "amount": "19158881.640000000000000000stake",
        "id": "1002-persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy"
      },
      {
        "validator": "persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy",
        "amount": "19158884.430000000000000000stake",
        "id": "1003-persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy"
      },
      {
        "validator": "persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy",
        "amount": "19158888.150000000000000000stake",
        "id": "1004-persistencevaloper1074vppsz6na2ur40psw2y4zx0up59vz2s52fdy"
      },
    ]
  }
}
~~~