VeChain Docs
  • Welcome to VeChain
  • Blockchain Basics
    • Introduction to blockchain
    • Introduction to digital property
    • The evolution of the internet
  • Introduction to VeChain
    • About the VeChain blockchain
      • Consensus Deep Dive
      • Governance
    • Dual-Token Economic Model
      • VeChain (VET)
      • VeThor (VTHO)
    • Acquire VeChain Assets
    • Sustainability
  • Core Concepts
    • Networks
      • Thor Solo Node
      • Testnet
      • Mainnet
    • Nodes
      • Node Rewards Programme
    • Blocks
      • Block Model
    • Transactions
      • Transaction Model
      • Transaction Fees
      • Transaction Calculation
      • Meta Transaction Features
        • Transaction Uniqueness
        • Controllable Transaction Lifecycle
        • Clauses (Multi-Task Transaction)
        • Fee Delegation
          • Multi-Party Payment (MPP)
          • Designated Gas Payer (VIP-191)
        • Transaction Dependency
    • Block Explorers
    • Wallets
      • VeWorld
        • User Guide
          • Setup
          • Wallet
          • Signing
          • Activities
          • Settings
        • FAQ
      • Sync2
        • User Guide
          • Setup
          • Wallet
          • Signing
          • Activities
          • Settings
        • FAQ
      • Sync
        • User Guide
          • Wallet
          • Ledger Device
          • Browser dApps and web
          • Interact with dApps
          • Activities
          • Settings
          • Report an Issue
          • Contributing
        • FAQ
    • EVM Compatibility
      • VeChain Modifications
      • Methodology
      • Test Coverage
        • Gas model
        • Raw transaction
        • hardhat specific
          • Ganache failures
          • evm_increaseTime
        • Failures in constructor
        • eth_sign
        • Contract address prediction
        • BadBeacon proxy address at 0x1
      • How to Recreate
      • Additional Information
        • Using Governance Contracts
        • ERC1820/ERC777 Testnet
        • Delegate Options
    • Account Abstraction
      • UserOperation
      • Bundler
      • EntryPoint Contract
      • Account Factory Contract
      • Paymaster Contract
    • Token Bound Accounts
  • How to run a node
    • Nodes
    • How to run a Thor Solo Node
    • Custom Network
    • Connect Sync2 to a Thor Solo Node
  • Developer Resources
    • Getting Started
    • How to build on VeChain
      • Connect to the Network
      • Read Data
        • Read Blocks
        • Read Transactions
        • Read Accounts
        • States & Views
        • Events & Logs
        • VET Transfers
      • Write Data
        • Transactions
        • Fee Delegation
      • Listen to Changes
        • Events
        • VET Transfers
        • Transactions
        • Blocks
        • Beats
      • Build with Hardhat
      • Utilities
        • BigInt and Unit-Handling
        • Name Service Lookups
    • Example dApps
      • Buy me a Coffee
      • Token Bound Accounts
      • PWA with Privy and Account Abstraction
    • EVM Compatibility for Developers
      • Key Architectural Differences and Optimizations
      • Practical Implications for Developers: Key Considerations
      • RPC Methods (Detailed Breakdown)
      • Frequently Asked Questions (FAQs)
      • VeChain Blockchain Specifications
      • Key Differences Between VeChain and Ethereum (Summary)
      • Best Practices for Developing on VeChainThor
    • How to verify Address-Ownership
      • Next.js Session Verification
    • Debug Reverted Transactions
    • Account Abstraction
    • VIP-191: Designated Gas Payer
      • How to Integrate VIP-191 (I)
      • How to Integrate VIP-191 (II)
      • How to Integrate VIP-191 (III)
    • Index with Graph Node
      • Setup with Docker
      • Index with OpenZeppelin
        • Create Subgraph Project
        • Configure Contracts
        • Deploy Subgraph and start Indexing
        • Track Subgraph Indexing
        • Access Subgraph
        • Update Subgraph
    • SDKs & Providers
      • SDK
        • Architecture
        • Accounts
        • Bloom Filter
        • Certificates
        • Contracts
        • Cryptography
        • Debug
        • Encoding
        • Polls
        • Subscriptions
        • Thor Client
        • Transactions
      • Thor DevKit
        • Installation
        • Usage
          • Cryptography
          • Accounts
          • Encoding
          • Transactions
          • Certificates
          • Bloom Filter
      • DApp Kit
        • v2
          • Installation
          • React
            • Installation
            • Usage
          • Vanilla JS
            • Installation
            • Usage
          • Core
            • Installation
            • Usage
          • Theme Variables
          • i18n
        • v1
          • Installation
          • React
            • Installation
            • Usage
          • Vanilla JS
            • Installation
            • Usage
          • Core
            • Installation
            • Usage
          • Theme Variables
          • i18n
          • Node Polyfills
          • V0 to V1
        • v0
          • Installation
          • Usage
          • React
            • Installation
            • Usage
          • Vanilla (UI)
            • Installation
            • Usage
          • Styles (UI)
          • i18n
      • DevPal
      • Web3-Providers-Connex
        • Installation
        • Usage
      • Connex
        • Installation
        • API Specification
    • Frameworks & IDEs
      • Hardhat
      • Remix
    • Built-in Contracts
    • VORJ
    • Useful Links
  • How to contribute
Powered by GitBook
On this page
  • codegen**** ****with example output
  • build with example output
  • graph create with example output
  • graph deploy with example output

Was this helpful?

  1. Developer Resources
  2. Index with Graph Node
  3. Index with OpenZeppelin

Deploy Subgraph and start Indexing

PreviousConfigure ContractsNextTrack Subgraph Indexing

Last updated 2 months ago

Was this helpful?

The are required to prepare subgraphs and interact with the graph node.

Install them with npm:

npm install --save @graphprotocol/graph-cli

Deploying the subgraph is a multi-step process:

  1. codegen generates AssemblyScript types from the subgraph's GraphQL schema and the contract ABIs included in the data sources. It must be run when either the schema or ABIs change.

  2. build generates the AssemblyScript from the subgraph's indexing scripts.

  3. graph create generates the namespace on the node where all the subgraph data will be stored. It must only be run once.

  4. graph deploy uploads the subgraph package to IPFS and instructs the graph node to use it.

codegen**** ****with example output

npx graph codegen vebetterdao/tokens.subgraph.yaml
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
  Apply migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
  Apply migration: Bump manifest specVersion from 0.0.2 to 0.0.4
✔ Apply migrations
✔ Load subgraph from vebetterdao/tokens.subgraph.yaml
  Load contract ABI from node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
  Load contract ABI from node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
✔ Load contract ABIs
  Generate types for contract ABI: IERC20 (node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json)
  Generate types for contract ABI: IERC20 (node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json)
  Write types to generated/erc20/IERC20.ts
  Write types to generated/erc20-1/IERC20.ts
✔ Generate types for contract ABIs
✔ Generate types for data source templates
✔ Load data source template ABIs
✔ Generate types for data source template ABIs
✔ Load GraphQL schema from vebetterdao/tokens.schema.graphql
  Write types to generated/schema.ts
✔ Generate types for GraphQL schema

Types generated successfully

build with example output

npx graph build vebetterdao/tokens.subgraph.yaml
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
  Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
  Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
✔ Apply migrations
✔ Load subgraph from vebetterdao/tokens.subgraph.yaml
  Compile data source: erc20 => build/erc20/erc20.wasm
  Compile data source: erc20-1 => build/erc20/erc20.wasm (already compiled)
✔ Compile subgraph
  Copy schema file build/tokens.schema.graphql
  Write subgraph file build/node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
  Write subgraph file build/node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
  Write subgraph manifest build/subgraph.yaml
✔ Write compiled subgraph to build/

Build completed: build/subgraph.yaml

graph create with example output

The create command needs to know the service URL of your Graph Node, which is http://127.0.0.1:8020 in the default setup:

npx graph create vebetterdao/tokens --node http://127.0.0.1:8020
 ›   Warning: In next major version, this command will be merged as a subcommand for `graph local`.
Created subgraph: vebetterdao/tokens

graph deploy with example output

The deploy command needs to know the service URL, the IPFS node to upload the subgraph package and the subgraph definition to upload. In the default setup, the service URL is http://127.0.0.1:8020 and the IPFS node is available on http://127.0.0.1:5001.

The previously generated vebetterdao/tokens.subgraph.yaml is the subgraph definition to upload. A version is required and is used to identify different deployments. In the local environment, versions can be ignored and re-used.

npx graph deploy vebetterdao/tokens --node http://127.0.0.1:8020 --ipfs http://127.0.0.1:5001 --version-label 1 vebetterdao/tokens.subgraph.yaml 
  Skip migration: Bump mapping apiVersion from 0.0.1 to 0.0.2
  Skip migration: Bump mapping apiVersion from 0.0.2 to 0.0.3
  Skip migration: Bump mapping apiVersion from 0.0.3 to 0.0.4
  Skip migration: Bump mapping apiVersion from 0.0.4 to 0.0.5
  Skip migration: Bump mapping apiVersion from 0.0.5 to 0.0.6
  Skip migration: Bump manifest specVersion from 0.0.1 to 0.0.2
  Skip migration: Bump manifest specVersion from 0.0.2 to 0.0.4
✔ Apply migrations
✔ Load subgraph from vebetterdao/tokens.subgraph.yaml
  Compile data source: erc20 => build/erc20/erc20.wasm
  Compile data source: erc20-1 => build/erc20/erc20.wasm (already compiled)
✔ Compile subgraph
  Copy schema file build/tokens.schema.graphql
  Write subgraph file build/node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
  Write subgraph file build/node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
  Write subgraph manifest build/subgraph.yaml
✔ Write compiled subgraph to build/
  Add file to IPFS build/tokens.schema.graphql
                .. QmTJC228tSzgV6ano5uSgVkk4yq3tdpUAZ11xBBnqtKbmm
  Add file to IPFS build/node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
                .. QmVkgbSMT9SrNoFcfxSdSmhghS2zz7Y6g3QxQ1xZ8HccrB
  Add file to IPFS build/node_modules/@openzeppelin/contracts/build/contracts/IERC20Metadata.json
                .. QmVkgbSMT9SrNoFcfxSdSmhghS2zz7Y6g3QxQ1xZ8HccrB (already uploaded)
  Add file to IPFS build/erc20/erc20.wasm
                .. QmWbi5wkYU15ksR7H4iMkQ7yZYXihPwb8qYfun7Ne1xcLn
  Add file to IPFS build/erc20/erc20.wasm
                .. QmWbi5wkYU15ksR7H4iMkQ7yZYXihPwb8qYfun7Ne1xcLn (already uploaded)
✔ Upload subgraph to IPFS

Build completed: QmezwJ1bGUGAUXehjg1qsTrycRVxsw29vFqVuN5fdzsE98

Deployed to http://127.0.0.1:8000/subgraphs/name/vebetterdao/tokens/graphql

Subgraph endpoints:
Queries (HTTP):     http://127.0.0.1:8000/subgraphs/name/vebetterdao/tokens

@graphprotocol/graph-cli