Skip to content

KenMan79/contracts-1

 
 

Repository files navigation

Graph Protocol Solidity Smart Contracts

Version Badge

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.

Contracts Testing

Testing is done with the following stack:

  • Waffle
  • Hardhat
  • Typescript
  • Ethers

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

Contract addresses

Currently we are running our testnet on Rinkeby. Contract addresses can be found in this repository at ./addresses.json. However, addresses should be obtained from the NPM Package.

Deploying Contracts

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

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.

Currently the contracts are being tested on Rinkeby. We test on ganache as well. We used to use Kovan, but it is somewhat deprecated.

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.

Copyright

Copyright © 2020 The Graph Foundation

Licensed under MIT license.

Packages

No packages published

Languages

  • TypeScript 58.7%
  • Solidity 40.8%
  • Other 0.5%