Skip to content

Commit e5d34e3

Browse files
authored
Update README - was very outdated (#219)
1 parent 8339baa commit e5d34e3

File tree

2 files changed

+86
-168
lines changed

2 files changed

+86
-168
lines changed

README.md

Lines changed: 86 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,104 @@
11
# Graph Protocol Solidity Smart Contracts
22

3-
![Version Badge](https://img.shields.io/badge/version-1.0.0-lightgrey.svg)
3+
![Version Badge](https://img.shields.io/badge/version-0.2.0-lightgrey.svg)
44
![WIP Badge](https://img.shields.io/badge/status-POC-blue.svg)
5-
[![Build Status](https://travis-ci.com/graphprotocol/contracts.svg?token=wbxCaTb68vuvzoN4HDgt&branch=master)](https://travis-ci.com/graphprotocol/contracts)
65

7-
## Subgraph
6+
## Overview
7+
### Contracts
88

9-
The subgraph can be found https://github.com/graphprotocol/graph-network-subgraph. The addresses
10-
for the subgraph need to be the most up to date. This includes grabbing the latest ABIs from here,
11-
as well as pointing the addresses in the subgraph manifest to the latest addresses. You can find
12-
the latest subgraph addresses below.
9+
This repository contains The Graph Protocol solidity contracts. It is based on the
10+
[PRD outlined here](https://www.notion.so/thegraph/Public-Network-Contracts-PRD-5eb8466aa4b44a1da7f16a28acd6674f),
11+
There are many other smaller, more detailed PRDs that these contracts implement, that can also be
12+
found on notion.
1313

14-
There are currently two networks we deploy to - Ropsten, and Ganache. The Ropsten addresses will
15-
change whenever there are updates to the contract, and we need to redeploy. This needs to be
16-
done in sync with deploying a new subgraph. The new GNS should point `thegraph` domain to the
17-
latest subgraph.
14+
The contracts enable a staking protocol build on top of Ethereum, using The Graph Network Token
15+
(GRT). The network enables a decentralized network of Graph Nodes
16+
to index and serve queries for subgraphs.
17+
[Graph node's repository can be found here](https://github.com/graphprotocol/graph-node).
1818

19-
We want to also run some test scripts to populate data each time new contracts are deployed.
19+
The Graph Network enables smart contract development to happen alongside subgraph development.
20+
It is a new and improved way to develop dapps. It allows developers to move some logic into the
21+
subgraph for resolving data based on events, or past storage data on Ethereum. Therefore,
22+
the contracts and the subgraph rely on each other, to show to end users the current data and state
23+
of The Graph Network.
2024

21-
See [DEPLOYMENT.md](./DEPLOYMENT.md) for instructions on deploying the contracts to the blockchain.
25+
### Subgraph
2226

23-
### Current Contract Addresses
27+
The subgraph repository can be [found here](https://github.com/graphprotocol/graph-network-subgraph).
2428

25-
See https://github.com/graphprotocol/contracts/blob/master/addresses.json.
29+
Great care must be taken to ensure all the code and data the subgraph refers to is in sync with
30+
the current contracts on the correct network. For tracking all of this, we have an NPM package.
2631

27-
### Subgraph Deployment Instructions
32+
The addresses
33+
for the subgraph need to be the most up to date. This includes grabbing the latest ABIs and
34+
typechain bindings, as well as pointing the addresses in the subgraph manifest to the latest
35+
addresses. You can find the latest subgraph addresses in `addresses.json`, and they are also
36+
in the NPM package.
2837

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

31-
Note, ganache MUST be ran with `ganache-cli -d -i 3859`. `-d` Makes the accounts the same for any
32-
instance of ganache, which allows us to have deterministic contract addresses. Therefore anyone can
33-
use the same subgraph manifest for ganache on their own laptop. `-i 99` is used to make the
34-
network ID constant, which helps with the subgraph. If you update the subgraph, you can just
35-
close ganache and start it up again and you can deploy. If you use the same subgraph ID though and
36-
reset ganche, you will have to drop the DB because it will have old data saved in it, with a new
37-
instance of ganache.
42+
### NPM package
43+
The NPM package will be release in versions, and the version will be coordinated to be the same
44+
version as the contracts and the subgraph. Anyone wanting to tie into the graph network contracts
45+
or subgraph should install the npm package into their repository, and refer to the same version
46+
number for the contracts and subgraph.
3847

39-
1. Run `ipfs daemon`
40-
2. In a new terminal run postrgres with `pg_ctl -D /usr/local/var/postgres -l logfile start`
41-
3. Create a database with `createdb graph-network-ganache`
42-
4. In a new terminal, run ganache with `ganche-cli -d -i 99`
43-
5. In a new terminal go to the `graph-node` repository start the subgraph with
48+
**New development work on the contracts and subgraph will be merged to master. Thus, when developing**
49+
**on the network, you should not rely on the master code as it might break between the subgraph repo**
50+
**and the contracts repo. Please use a version that is tagged.**
4451

52+
The NPM package will contain the following files/information:
53+
- The contracts
54+
- The ABIs for those contracts
55+
- The typechain autogenerated functions. These are typescript functions that are created based off
56+
the ABIs, and are very useful for their type checking and the fact they are tied to a version
57+
- The deployed addresses for each network, the date of deployment, and the commit hash.
58+
- Metadata JSON objects for Graph Account and Subgraph metadata
59+
**This is the only place you should grab contract addresses from.**
60+
61+
We will also release versions for specific releases, such as `@graphprotocol/contracts@beta`.
62+
63+
## Contracts Testing
64+
65+
Testing is done with the following stack:
66+
- Waffle
67+
- Buidler
68+
- Typescript
69+
- Ethers
70+
71+
To test all files, use `npm run test`. To test a single file run:
72+
`npx buidler test test/<FILE_NAME>.ts`.
73+
74+
## Deployments
75+
76+
Currently we are only deployed on kovan. Contract addresses can be found in this repository at
77+
`./addresses.json`. However, addresses should be obtained from the NPM Package.
78+
79+
### Mainnet
80+
Not deployed yet.
81+
82+
### Kovan
83+
Deployed. Note that we had to get ENS to deploy an unofficial version of the contracts on ENS.
84+
While quickly testing, we will use the test registrar. When we get a testnet on a different
85+
testnet we will use the normal `.eth` domain, while as with the test registrar we use the
86+
`.test` one. This will be hidden by the indexing of the subgraph anyways.
87+
88+
**Kovan ENS:**
4589
```
46-
cargo run -p graph-node --release -- \
47-
--postgres-url postgresql://davidkajpust@localhost:5432/graph-network-ganache \
48-
--ethereum-rpc ganache:http://127.0.0.1:8545 \
49-
--ipfs 127.0.0.1:5001 \
50-
--debug \
90+
PublicResolver 0xc30F6CCc48F1eA5374aC618dfe5243ddD1e264E7
91+
ETHRegistryWithFallback 0xB66B2f307B6e46a6D038a85997B401aE87455772
92+
ETHRegistrarController 0x7966398e99a60c7b3465A394B22C0b5ce1012EC9
93+
Root. 0x821164869e097c7fEcD301EE68d2231A3565D5C9
94+
TestRegistrar: 0x327033bA7B23A6E3a3Ca165e44D619E3dd675f8b
95+
ReverseRegistrar 0xCE228fF5EFCE6403Cd011046138488FF31C05Da9
5196
```
5297

53-
6. In a new terminal go to the `graph-network-subgraph` repository, and create the subgraph with
54-
`yarn create-local` (NOTE - MAKE SURE THE CONTRACT ADDRESSES IN THE MANIFEST ARE SET TO THE
55-
GANACHE ADDRESSES!)
56-
7. Then deploy it with `yarn deploy-local`
57-
58-
At this point, everything is setup. You can then interact with the contracts through Remix, or
59-
our graph explorer UI, or through our automated scripts. Real automated scripts will be added soon,
60-
but for now you can run `npm run test` and it will run all the tests, and execute transactions,
61-
which will allow the subgraph to store data.
62-
63-
#### Ropsten
64-
65-
(Note we use the graph hosted service right now to deploy to. We do not use the new Dapp explorer UI
66-
to create and deploy subgraphs. It can be found [here](https://staging.thegraph.com/explorer/subgraph/graphprotocol/explorer-dapp)
67-
]. The subgraph is already created, so we will only mention how to update the subgraph here.
68-
69-
1. Deploy new contracts to Ropsten with `npm run deploy -- --network ropsten`. Truffle stores the
70-
addresses for networks, so if you are trying to re-deploy you may have to run
71-
`truffle networks —clean`, and then deploy.
72-
2. Get the new contract addresses from the deployment. They are logged in the terminal output from
73-
deploying. Put these contract addresses into the subgraph manifest
74-
3. Make sure you are a member of `graphprotocol` for the staging explorer application
75-
4. Then make sure you have the right access token for `graphprotocol`. You can set this up with
76-
`graph auth https://api.thegraph.com/deploy/ <ACCESS_TOKEN>`. You can get it from the dashboard in the
77-
UI, just pick `graphprotocol` instead of your own account, and you will see the token.
78-
5. Then in the `graph-network-subgraph` repository, just run `yarn deploy` to update a new version
79-
6. You will also have to update information in the `graph-explorer-dapp` repo. You must update
80-
the contract addresses in the `.env.development` file, and you need to update the contract addresses
81-
in the cloud build file
82-
https://github.com/graphprotocol/graph-explorer-dapp/blob/master/cloudbuild.staging.yaml
83-
84-
At some point in the future we will work on having scripts that will populate data in the subgraph
85-
on ropsten, so we can better test.
86-
87-
## Installation &amp; Deployment of Contracts
88-
89-
1. Install Node.js `v10.15.1`.
90-
2. Run `npm install` at project root directory.
91-
3. Install and run `testrpc`, `ganache-cli`, or similar blockchain emulator.
92-
- Configure to run on port `8545` or edit `buidler.config.ts` to change the port used by Buidler.
93-
4. Build
94-
- `npm run build` (compile contracts, flatten code, export ABIs and create Typescript bindings)
95-
- `npm run migrate` (deploy contracts to local blockchain emulator)
96-
- `npm run test` (runs tests)
97-
5. See [DEPLOYMENT.md](./DEPLOYMENT.md) for instructions on deploying the contracts to the blockchain.
98-
99-
## Abstract
100-
101-
This repository will contain the Solidity smart contracts needed to facilitate the processes defined in the Product Requirements Document provided by The Graph.
102-
(see: [PRD on Notion](https://www.notion.so/Hybrid-POC-Smart-Contracts-18646757d3644f73bf9fdfb2e98b93eb))
103-
104-
![Imgur](https://i.imgur.com/9uwiie1.png)
105-
106-
## Graph Protocol Contracts
107-
108-
1. [Graph Token](./contracts/GraphToken.sol)
109-
2. [Staking](./contracts/Staking.sol)
110-
3. [Dispute Resolution](./contracts/DisputeManager.sol)
111-
4. [Graph Name Service (GNS)](./contracts/GNS.sol)
112-
5. [Rewards Manager](./contracts/RewardsManager.sol)
113-
6. [Service Registry](./contracts/ServiceRegistry.sol)
114-
7. [Governance](./contracts/Governed.sol)
115-
116-
### Supporting Contracts
117-
118-
1. [MultiSig Contract](./contracts/MultiSigWallet.sol) (by Gnosis)
119-
2. [Detailed, Mintable, Burnable ERC20 Token](./contracts/openzeppelin/) (by Open Zeppelin)
120-
3. [Bonding Curve Formulas](./contracts/bancor/) (by Bancor)
121-
122-
_[See ./contracts/README.md for full list of contracts](./contracts/)_
98+
### Ropsten/Rinkeby/Goerli
99+
One of these networks will be added in the future, to test the network with 15 second block times.
100+
This will likely become the real network we run testnet on with node operators, or else we will
101+
run our own private network.
102+
103+
In order to run deployments, see `./DEPLOYMENT.md`. We use a custom deployment script, which
104+
allowed us to completely remove `truffle` as a dependency.

contracts/README.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)