This repository contains Threshold Network staking subgraphs.
Subgraphs are open APIs to query data from networks like Ethereum and IPFS. The data is indexed by The Graph decentralized protocol.
By the moment, there two different subgraphs have been developed: - mainnet: collects the data from contracts in Ethereum Mainnet. - mumbai: collects the data from contracts in Polygon Mumbai.
Development query URL for Ethereum mainnet subgraph: https://api.studio.thegraph.com/query/24143/main-threshold-subgraph/0.0.7
Development query URL for Polygon subgraph: https://api.studio.thegraph.com/query/24143/threshold-staking-polygon/0.1.0
Development query URL for Simple PRE Application: https://api.studio.thegraph.com/query/24143/simple-pre-application/version/latest
Please make sure you have the following prerequisites installed on your machine:
The Graph CLI can be installed in your computer with npm or yarn:
$ yarn global add @graphprotocol/graph-cli
Once graph-cli is installed in your system, install linting and formatting tools:
$ yarn install
Now, you can navigate to the subgraph of your interest and install this subgraph dependencies:
$ cd subgraphs/mainnet/
$ yarn install
The recommended way to run tests is using a Docker container. It is required to have [Docker installed](https://docs.docker.com/desktop/).
To run the tests, just execute:
$ yarn test
Tests can also be run in the local environment, more info in [Unit Testing Framework](https://thegraph.com/docs/en/developing/unit-testing-framework/).
Subgraphs can be deployed in Subgraph Studio. It is required to create a new
subgraph in Subgraph Studio and get a deploy
key
.
Once the new subgraph is created in Subgraph Studio, you have to authenticate in graph-cli:
$ graph auth --studio <DEPLOY KEY>
And then you can deploy the subgraph. Follow the CLI instructions:
$ graph deploy --studio
Note that host set to 0.0.0.0
is necessary for Ganache to be accessible from
within Docker and from other machines. By default, Ganache only binds to
127.0.0.1, which can only be accessed from the host machine that Ganache runs
on. If you use a ganache-cli run the node with ganache-cli -h 0.0.0.0
. If you
use a Ganche in GUI version go to settings → server
and set HOSTNAME
to
0.0.0.0 - All Interfaces
. Make sure the network ID is the same as chaind ID.
By default, ganache sets the chaind ID to 1337
. To change the network ID in
Ganache GUI go to settings → server
and set NETWORK ID
to 1337
. If you
use a ganache-cli run a node with flag -i 1337
.
Clone https://github.com/threshold-network/solidity-contracts repo and make sure
the development
network config in
hardhat.config.ts
is correct for your local chain.
Note
|
The deployment scripts assume the keep-core contract are already
deployed to your local chain.
|
Clone https://github.com/keep-network/keep-core repo and make sure the local
network config in
truffle-config.js
is correct for your local chain.
Go to root dir and run ./scripts/install.sh --network local --contracts-only
.
Go to ./solidity-v1
and run yarn link
.
Set the correct address
and startBlock
for contracts in subgraph.yaml
file.