Skip to content

graphprotocol/contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graph Protocol Solidity Smart Contracts

Version Badge WIP Badge

Overview

Contracts

This repository contains The Graph Protocol solidity contracts. It is based on the PRD outlined here, There are many other smaller, more detailed PRDs that these contracts implement, that can also be found on notion.

The contracts enable a staking protocol build on top of Ethereum, using The Graph Network Token (GRT). The network enables a decentralized network of Graph Nodes to index and serve queries for subgraphs. Graph node's repository can be found here.

The Graph Network enables smart contract development to happen alongside subgraph development. It is a new and improved way to develop dapps. It allows developers to move some logic into the subgraph for resolving data based on events, or past storage data on Ethereum. Therefore, the contracts and the subgraph rely on each other, to show to end users the current data and state of The Graph Network.

Subgraph

The subgraph repository can be found here.

Great care must be taken to ensure all the code and data the subgraph refers to is in sync with the current contracts on the correct network. For tracking all of this, we have an NPM package.

The addresses for the subgraph need to be the most up to date. This includes grabbing the latest ABIs and typechain bindings, as well as pointing the addresses in the subgraph manifest to the latest addresses. You can find the latest subgraph addresses in addresses.json, and they are also in the NPM package.

There are currently two networks we deploy to - Kovan, and Ganache. The Kovan addresses will change whenever there are updates to the contract. This needs to be done in sync with deploying a new subgraph.

NPM package

The NPM package will be release in versions, and the version will be coordinated to be the same version as the contracts and the subgraph. Anyone wanting to tie into the graph network contracts or subgraph should install the npm package into their repository, and refer to the same version number for the contracts and subgraph.

New development work on the contracts and subgraph will be merged to master. Thus, when developing on the network, you should not rely on the master code as it might break between the subgraph repo and the contracts repo. Please use a version that is tagged.

The NPM package will contain the following files/information:

  • The contracts
  • The ABIs for those contracts
  • The typechain autogenerated functions. These are typescript functions that are created based off the ABIs, and are very useful for their type checking and the fact they are tied to a version
  • The deployed addresses for each network, the date of deployment, and the commit hash.
  • Metadata JSON objects for Graph Account and Subgraph metadata This is the only place you should grab contract addresses from.

We will also release versions for specific releases, such as @graphprotocol/contracts@beta.

Contracts Testing

Testing is done with the following stack:

  • Waffle
  • Buidler
  • Typescript
  • Ethers

To test all files, use npm run test. To test a single file run: npx buidler test test/<FILE_NAME>.ts.

Deployments

Currently we are only deployed on kovan. Contract addresses can be found in this repository at ./addresses.json. However, addresses should be obtained from the NPM Package.

Mainnet

Not deployed yet.

Kovan

Deployed. Note that we had to get ENS to deploy an unofficial version of the contracts on ENS. While quickly testing, we will use the test registrar. When we get a testnet on a different testnet we will use the normal .eth domain, while as with the test registrar we use the .test one. This will be hidden by the indexing of the subgraph anyways.

Kovan ENS:

PublicResolver 0xc30F6CCc48F1eA5374aC618dfe5243ddD1e264E7
ETHRegistryWithFallback 0xB66B2f307B6e46a6D038a85997B401aE87455772
ETHRegistrarController 0x7966398e99a60c7b3465A394B22C0b5ce1012EC9
Root. 0x821164869e097c7fEcD301EE68d2231A3565D5C9
TestRegistrar: 0x327033bA7B23A6E3a3Ca165e44D619E3dd675f8b
ReverseRegistrar 0xCE228fF5EFCE6403Cd011046138488FF31C05Da9

Ropsten/Rinkeby/Goerli

One of these networks will be added in the future, to test the network with 15 second block times. This will likely become the real network we run testnet on with node operators, or else we will run our own private network.

In order to run deployments, see ./DEPLOYMENT.md. We use a custom deployment script, which allowed us to completely remove truffle as a dependency.