Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Contracts repository for The Graph protocol

License

NotificationsYou must be signed in to change notification settings

graphprotocol/contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,503 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Graph

The Graph Protocol

A decentralized network for querying and indexing blockchain data.

BuildCI-Contracts

PackagesDevelopmentDocsContributingSecurityLicense


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.

Packages

This repository is a pnpm workspaces monorepo containing the following packages:

PackageLatest versionDescription
contractsnpm versionContracts enabling the open and permissionless decentralized network known as The Graph protocol.
data-edgenpm versionData edge testing and utilities for The Graph protocol.
hardhat-graph-protocolnpm versionA Hardhat plugin that extends the runtime environment with functionality for The Graph protocol.
horizonnpm versionContracts for Graph Horizon, the next iteration of The Graph protocol.
interfacesnpm versionContract interfaces for The Graph protocol contracts.
issuancenpm versionSmart contracts for The Graph's token issuance functionality
subgraph-servicenpm versionContracts for the Subgraph data service in Graph Horizon.
token-distributionnpm versionContracts managing token locks for network participants.
toolshednpm versionA collection of tools and utilities for the Graph Protocol TypeScript components.

Development

Setup

To set up this project you'll needgit andpnpm installed.

From your command line:

corepackenablepnpmset 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$ pnpmtest

Script Patterns

This monorepo follows consistent script patterns across all packages to ensure reliable builds and tests:

Build Scripts

  • pnpm build (root) - Builds all packages by callingbuild:self on each
  • pnpm build (package) - Builds dependencies first, then the package itself
  • pnpm build:self - Builds only the current package (no dependencies)
  • pnpm build:dep - Builds workspace dependencies needed by the current package

Test Scripts

  • pnpm test (root) - Builds everything once, then runstest:self on all packages
  • pnpm test (package) - Builds dependencies first, then runs tests
  • pnpm test:self - Runs only the package's tests (no building)
  • pnpm test:coverage (root) - Builds everything once, then runstest:coverage:self on all packages
  • pnpm test:coverage (package) - Builds dependencies first, then runs coverage
  • pnpm test:coverage:self - Runs only the package's coverage tests (no building)

Key Benefits

  • Efficiency: Rootpnpm test builds 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

Examples

# Build everything from rootpnpm build# Test everything from root (builds once, tests all)pnpmtest# Test a specific package (builds its dependencies, then tests)cd packages/horizon&& pnpmtest# Test without building (assumes dependencies already built)cd packages/horizon&& pnpm test:self

Versioning and publishing packages

We usechangesets to manage package versioning, this ensures that all packages are versioned together in a consistent manner and helps with generating changelogs.

Step 1: Creating a changeset

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 changeset

Changeset 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.

Step 2: Creating a package 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 version

Step 3: Tagging the release

Note: 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 taggit push --follow-tags

Step 4: Publishing a package release

Note: 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 packagespnpm changeset publish# Alternatively usepnpm publish --recursive

Alternatively, there is a GitHub action that can be manually triggered to publish a package.

Linting

This monorepo uses multiple linting tools: ESLint, Prettier, Solhint, Forge Lint, Markdownlint, and YAML Lint.

pnpm lint# Run all linterspnpm lint:staged# Lint only staged files

Seedocs/Linting.md for detailed configuration, inline suppression syntax, and troubleshooting.

Documentation

Coming soon

For now, each package has its own README with more specific documentation you can check out.

Contributing

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 toThe Graph Discord orThe Graph Forum and discuss your idea! Discussions on the forum or Discord are another great way to contribute.

Security

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.

License

Copyright © 2021 The Graph Foundation

Licensed underGPL license.


[8]ページ先頭

©2009-2026 Movatter.jp