Packages • Development • Docs • Contributing • Security • License
The Graph is an indexing protocol for querying networks like Ethereum, IPFS, Polygon, and other blockchains. Anyone can build and Publish open APIs, called subgraphs, making data easily accessible.
This repository is a pnpm workspaces monorepo containing the following packages:
| Package | Latest version | Description |
|---|---|---|
| contracts | Contracts enabling the open and permissionless decentralized network known as The Graph protocol. | |
| data-edge | Data edge testing and utilities for The Graph protocol. | |
| hardhat-graph-protocol | A Hardhat plugin that extends the runtime environment with functionality for The Graph protocol. | |
| horizon | Contracts for Graph Horizon, the next iteration of The Graph protocol. | |
| interfaces | Contract interfaces for The Graph protocol contracts. | |
| issuance | Smart contracts for The Graph's token issuance functionality | |
| subgraph-service | Contracts for the Subgraph data service in Graph Horizon. | |
| token-distribution | Contracts managing token locks for network participants. | |
| toolshed | A collection of tools and utilities for the Graph Protocol TypeScript components. |
To set up this project you'll need git and pnpm installed.
From your command line:
corepack enable
pnpm set version stable
# Clone this repository
$ git clone https://github.com/graphprotocol/contracts
# Go into the repository
$ cd contracts
# Install dependencies
$ pnpm install
# Build projects
$ pnpm build
# Run tests
$ pnpm testThis monorepo follows consistent script patterns across all packages to ensure reliable builds and tests:
pnpm build(root) - Builds all packages by callingbuild:selfon eachpnpm build(package) - Builds dependencies first, then the package itselfpnpm build:self- Builds only the current package (no dependencies)pnpm build:dep- Builds workspace dependencies needed by the current package
pnpm test(root) - Builds everything once, then runstest:selfon all packagespnpm test(package) - Builds dependencies first, then runs testspnpm test:self- Runs only the package's tests (no building)pnpm test:coverage(root) - Builds everything once, then runstest:coverage:selfon all packagespnpm test:coverage(package) - Builds dependencies first, then runs coveragepnpm test:coverage:self- Runs only the package's coverage tests (no building)
- Efficiency: Root
pnpm testbuilds once, then tests all packages - Reliability: Individual package tests always ensure dependencies are built
- Consistency: Same patterns work at any level (root or package)
- Child Package Support: Packages with child packages delegate testing appropriately
# Build everything from root
pnpm build
# Test everything from root (builds once, tests all)
pnpm test
# Test a specific package (builds its dependencies, then tests)
cd packages/horizon && pnpm test
# Test without building (assumes dependencies already built)
cd packages/horizon && pnpm test:selfWe use changesets to manage package versioning, this ensures that all packages are versioned together in a consistent manner and helps with generating changelogs.
A changeset is a file that describes the changes that have been made to the packages in the repository. To create a changeset, run the following command from the root of the repository:
pnpm changesetChangeset files are stored in the .changeset directory until they are packaged into a release. You can commit these files and even merge them into your main branch without publishing a release.
When you are ready to create a new package release, run the following command to package all changesets, this will also bump package versions and dependencies:
pnpm changeset versionNote: this step is meant to be run on the main branch.
After creating a package release, you will need to tag the release commit with the version number. To do this, run the following command from the root of the repository:
pnpm changeset tag
git push --follow-tagsNote: this step is meant to be run on the main branch.
Packages are published and distributed via NPM. To publish a package, run the following command from the root of the repository:
# Publish the packages
pnpm changeset publish
# Alternatively use
pnpm publish --recursiveAlternatively, there is a GitHub action that can be manually triggered to publish a package.
This monorepo uses multiple linting tools: ESLint, Prettier, Solhint, Forge Lint, Markdownlint, and YAML Lint.
pnpm lint # Run all linters
pnpm lint:staged # Lint only staged filesSee docs/Linting.md for detailed configuration, inline suppression syntax, and troubleshooting.
Coming soon
For now, each package has its own README with more specific documentation you can check out.
Contributions are welcomed and encouraged! You can do so by:
- Creating an issue
- Opening a PR
If you are opening a PR, it is a good idea to first go to The Graph Discord or The Graph Forum and discuss your idea! Discussions on the forum or Discord are another great way to contribute.
If you find a bug or security issue please go through the official channel, The Graph Security Bounties on Immunefi. Responsible disclosure procedures must be followed to receive bounties.
Copyright © 2021 The Graph Foundation
Licensed under GPL license.
