• Stars
    star
    140
  • Rank 253,703 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Subgraph schema and templates to index the activity of OpenZeppelin Contracts.

OpenZeppelin Subgraphs

Introduction

This repo contains subgraph schema and templates to index the activity of OpenZeppelin Contracts. For each of the supported OpenZeppelin modules x, this repo provides:

  • Primitives to generate a graphql schema: src/datasource/x.gql.json

    In order to allow composability, the schema are not defined in the graphql format but rather in a dedicated json format which can be assembled and compiled to graphql using the graph-compiler tool from @amxx/graphprotocol-utils. Graphql version for each module is also available in generated/x.schema.graphql

  • Template to generate a subgraph manifest: src/datasource/x.yaml

    This file lists all the events that the datasources should listen to, and links that to the corresponding indexing logic. Similarly to the schema, the manifest can be generated procedurally from a JSON app description.

  • Indexing logic: src/datasources/x.ts and (optionally) src/fetch/x.ts

    This is the core logic that processes the events and to index the onchain activity.

Suported modules

  • AccessControl
  • ERC20
  • ERC721
  • ERC1155
  • ERC1967Upgrade
  • Governor
  • Ownable
  • Pausable
  • Timelock

Usage

To use OpenZeppelin Subgraphs, install them in your local project directory and follow the steps outlined in How to build my app's subgraph:

npm install @openzeppelin/subgraphs

How to build my app's subgraph

In order to build your subgraph, the first step is to create a JSON file listing the modules you want to index. Examples of such config can be found in the config folder.

For example, configs/sample.json describes an app with 4 contracts, the first one is an ERC20 with AccessControl, while the 3 others are ERC721 registries.

{
  "output": "generated/sample.",
  "chain": "mainnet",
  "datasources": [
    { "address": "0xA3B26327482312f70E077aAba62336f7643e41E1", "startBlock": 11633151, "module": [ "erc20", "accesscontrol" ] },
    { "address": "0xB1C52075b276f87b1834919167312221d50c9D16", "startBlock":  9917641, "module": "erc721" },
    { "address": "0x799DAa22654128d0C64d5b79eac9283008158730", "startBlock":  9917642, "module": "erc721" },
    { "address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4", "startBlock":  9917639, "module": "erc721" }
  ]
}

It can be compiled by doing

npx graph-compiler \
  --config configs/sample.json \
  --include node_modules/@openzeppelin/subgraphs/src/datasources \
  --export-schema \
  --export-subgraph

This will create two files: generated/sample.schema.graphql and generated/sample.subgraph.yaml that can be used to build and deploy the corresponding subgraph.

Note: startBlock is optional but will improve your subgraph initial indexing speed.

Live deployments

Admin (Access Control + Ownable + ERC1967)

Network Config Queries (HTTP) Subscriptions (WS)
Mainnet configs/live/mainnet/admin.json https://api.thegraph.com/subgraphs/name/amxx/access-control wss://api.thegraph.com/subgraphs/name/amxx/access-control
BSC configs/live/bsc/admin.json https://api.thegraph.com/subgraphs/name/amxx/access-control-bsc wss://api.thegraph.com/subgraphs/name/amxx/access-control-bsc
Matic configs/live/matic/admin.json https://api.thegraph.com/subgraphs/name/amxx/access-control-matic wss://api.thegraph.com/subgraphs/name/amxx/access-control-matic
XDai configs/live/xdai/admin.json https://api.thegraph.com/subgraphs/name/amxx/access-control-xdai wss://api.thegraph.com/subgraphs/name/amxx/access-control-xdai

NFTs (ERC721 + ERC1155)

Network Config Queries (HTTP) Subscriptions (WS)
Mainnet configs/live/mainnet/nfts.json https://api.thegraph.com/subgraphs/name/amxx/nft-mainnet wss://api.thegraph.com/subgraphs/name/amxx/nft-mainnet
BSC configs/live/bsc/nfts.json https://api.thegraph.com/subgraphs/name/amxx/nft-bsc wss://api.thegraph.com/subgraphs/name/amxx/nft-bsc
Matic configs/live/matic/nfts.json https://api.thegraph.com/subgraphs/name/amxx/nft-matic wss://api.thegraph.com/subgraphs/name/amxx/nft-matic
XDai configs/live/xdai/nfts.json https://api.thegraph.com/subgraphs/name/amxx/nft-xdai wss://api.thegraph.com/subgraphs/name/amxx/nft-xdai

ERC721 only

Network Config Queries (HTTP) Subscriptions (WS)
Mainnet configs/live/mainnet/eip721.json https://api.thegraph.com/subgraphs/name/amxx/eip721-subgraph wss://api.thegraph.com/subgraphs/name/amxx/eip721-subgraph

ERC1155 only

Network Config Queries (HTTP) Subscriptions (WS)
Mainnet configs/live/mainnet/eip1155.json https://api.thegraph.com/subgraphs/name/amxx/eip1155-subgraph wss://api.thegraph.com/subgraphs/name/amxx/eip1155-subgraph

More Repositories

1

openzeppelin-contracts

OpenZeppelin Contracts is a library for secure smart contract development.
JavaScript
24,223
star
2

ethernaut

Web3/Solidity based wargame
Solidity
1,910
star
3

openzeppelin-contracts-upgradeable

Upgradeable variant of OpenZeppelin Contracts, meant for use in upgradeable contracts.
JavaScript
947
star
4

cairo-contracts

OpenZeppelin Contracts written in Cairo for Starknet, a decentralized ZK Rollup
Rust
781
star
5

awesome-openzeppelin

Blockchain educational resources curated by the OpenZeppelin team
741
star
6

damn-vulnerable-defi

Solidity
644
star
7

openzeppelin-upgrades

Plugins for Hardhat and Foundry to deploy and manage upgradeable contracts on Ethereum.
TypeScript
596
star
8

openzeppelin-sdk

OpenZeppelin SDK repository for CLI and upgrades.js. No longer actively developed.
JavaScript
433
star
9

solidity-docgen

Documentation generator for Solidity projects
TypeScript
428
star
10

workshops

Code and slides for OpenZeppelin Workshops
JavaScript
422
star
11

openzeppelin-test-helpers

Assertion library for Ethereum smart contract testing
JavaScript
415
star
12

merkle-tree

A JavaScript library to generate merkle trees and merkle proofs.
TypeScript
407
star
13

openzeppelin-labs

A space for the community to interact and exchange ideas on the OpenZeppelin platform. Do not use in production!
JavaScript
374
star
14

nile

CLI tool to develop StarkNet projects written in Cairo
Python
323
star
15

contracts-wizard

Interactive smart contract generator based on OpenZeppelin Contracts.
TypeScript
233
star
16

exploit-uniswap

Exploiting a Uniswap exchange that uses an ERC777 token by leveraging the reentrant microtrading attack vector
JavaScript
172
star
17

openzeppelin-foundry-upgrades

Foundry library for deploying and managing upgradeable contracts
Solidity
132
star
18

solidity-jwt

Experiments with Solidity JWT. Do not use in production.
Solidity
131
star
19

starter-kit

An OpenZeppelin starter kit containing React, OpenZeppelin SDK & OpenZeppelin Contracts.
JavaScript
122
star
20

token-vesting-ui

UI for TokenVesting contract from OpenZeppelin. No longer maintained
JavaScript
97
star
21

openzeppelin-test-environment

[Not actively maintained] One-line setup for blazing-fast smart contracts tests
Solidity
90
star
22

solidity-ast

TypeScript types and a JSON Schema for the Solidity AST
JavaScript
88
star
23

ctf-2024

⚑️ Ethernaut CTF 2024 Challenges & Solutions
Solidity
72
star
24

contract-bots-gang

TypeScript
69
star
25

sample-crowdsale-starter

Empty sample starter truffle project for using zeppelin-solidity for a crowdsale
JavaScript
67
star
26

nile-rs

CLI tool to develop Starknet projects written in Cairo
Rust
56
star
27

defender-client

Monorepo for all defender-client npm packages
TypeScript
56
star
28

defender-autotask-examples

Example snippets for Defender Autotasks
JavaScript
48
star
29

crafty

A collectibles crafting game. Built using the OpenZeppelin SDK.
JavaScript
48
star
30

polkadot-runtime-templates

A generic template for Substrate Runtime
Rust
45
star
31

openzeppelin-network.js

An easy to use and reliable library that provides one line access to Web3 API.
TypeScript
44
star
32

docs.openzeppelin.com

Source for the OpenZeppelin documentation site
SCSS
43
star
33

starter-kit-gsn

An OpenZeppelin starter kit focused on GSN.
JavaScript
40
star
34

openzeppelin-gsn-provider

Web3 provider for the Gas Station Network
JavaScript
39
star
35

starter-kit-tutorial

An OpenZeppelin starter kit tutorial containing React, OpenZeppelin SDK & OpenZeppelin Contracts.
JavaScript
38
star
36

defender-docs

Security Management to Protect the Open Economy
31
star
37

openzeppelin.org

Source code for OpenZeppelin website
23
star
38

compound-monitoring

JavaScript
22
star
39

defender-templates

Templates for using OpenZeppelin Defender using Serverless configurations
JavaScript
22
star
40

openzeppelin-gsn-helpers

Test and development helper methods and scripts for GSN
JavaScript
21
star
41

upgrades-safe-app

TypeScript
20
star
42

gsn-sample-chat_app

OpenZeppelin starter-kit based GSN tutorial for a Chat App
JavaScript
20
star
43

openzeppelin-transpiler

TypeScript
20
star
44

defender-serverless

Configure a Defender environment via code
TypeScript
20
star
45

gnosis-multisig

Allows multiple parties to agree on transactions before execution. Forked from Gnosis multisig repository.
CSS
20
star
46

configs

Code style guidelines and rules for OpenZeppelin projects
JavaScript
19
star
47

openzeppelin-contracts-docs

OpenZeppelin documentation site configuration
JavaScript
19
star
48

defender-example-metatx-relay

Example meta-tx relay built using Defender
JavaScript
16
star
49

accesscontrol-explorer

Work in progress explorer for AccessControl roles
Svelte
15
star
50

openzeppelin-contract-loader

Load contract ABIs from built artifacts and return contract objects
JavaScript
15
star
51

sample-crosschain-env

Test environments for crosschain operations
Shell
15
star
52

openzeppelin-whitepaper

LaTeX sources for the OpenZeppelin Platform Whitepaper
Makefile
14
star
53

erc20-onboarding

ERC20 token on-boarding on the OpenZeppelin SDK platform
JavaScript
14
star
54

openzeppelin.com

Main website of OpenZeppelin
HTML
13
star
55

defender-sdk

Defender SDK
TypeScript
12
star
56

ethernaut-leaderboard

JavaScript
11
star
57

openzeppelin-team-nft

NFT for OpenZeppelin Team
JavaScript
11
star
58

solidity-loader

Solidity Hot Loader for Starter Kits. Not currently maintained
JavaScript
11
star
59

proxy-explorer

πŸ‘· Under construction!
TypeScript
11
star
60

gsn-site

The Ethereum Gas Station Network Alliance Landing Page and Tools
JavaScript
11
star
61

openzeppelin-nile-upgrades

Plugin for Nile to deploy and manage upgradeable contracts on StarkNet.
Python
10
star
62

proposal143

Solidity
10
star
63

compound-re-enable-dsr-proposal

Foundry simulation for Compound Proposal for re-enabling MakerDAO DSR
Solidity
10
star
64

highlightjs-cairo

JavaScript
8
star
65

gsn-relayer

GSN relayer server, forked from openeth-dev/gsn
Go
8
star
66

web3-gsn-faucet-provider

JavaScript
8
star
67

token-vouching

Vouching contracts and scripts for the OpenZeppelin SDK token
JavaScript
7
star
68

compound-governance-proposal-behavior

Set of tests to reflect the proposal lifecycle behavior
Solidity
7
star
69

defender-as-code

TypeScript
7
star
70

zeppelin.solutions

Institutional website
6
star
71

research-cryptography

OpenZeppelin Research group working repository
Jupyter Notebook
6
star
72

openzeppelin-token-registry

OpenZeppelin Ethereum Packages registry
JavaScript
5
star
73

access-manager-explorer

TypeScript
5
star
74

compound-assets-listing

Template repo to define assets listing on Compound
4
star
75

compound-security-policies

Security roles and responsibilities for Compound
4
star
76

fuzzy-import-parser

TypeScript
4
star
77

gsn-tools

Set of tools to manage the GSN
JavaScript
4
star
78

docs-utils

Scripts used for docs previews in pull requests across OpenZeppelin projects
JavaScript
4
star
79

secure-development-cookbook

The essential blueprint for crafting secure protocols
JavaScript
4
star
80

discourse-highlightjs-langs

HTML
3
star
81

openzeppelin-upgrades-migration-example

3
star
82

governor-quorum-bot

Forta detection bot to alert about changes in quorum quantity in a Governor contract
TypeScript
3
star
83

polkadot-evm-runtime-template

EVM runtime template for Polkadot parachains
Rust
3
star
84

defender-serverless-workshop

JavaScript
2
star
85

futureswap-artifacts

Compiled bytecode related to our FutureSwap audits for public viewing
2
star
86

cto.openzeppelin.com

Description of the CTO job opening at OpenZeppelin
HTML
2
star
87

ctf-infra

🧱 Infrastructure for Ethernaut CTF 2024
Python
2
star
88

tech-coaching

A place to keep study materials associated with the tech coaching
HTML
2
star
89

slack.openzeppelin.org

https://openzeppelin-slack.netlify.com/ Source for https://slack.openzeppelin.org/
1
star
90

sgp

Solidity ANTLR4 grammar Python parser
Python
1
star
91

netlify-redirects

Redirection rules for various old websites
1
star
92

defender-subgraphs

Access Control subgraph toolkit for Defender
TypeScript
1
star