Skip to content

getSubgraphEndpoint

Returns the appropriate subgraph endpoint URL for a given chain ID. This method maps blockchain network identifiers to their corresponding Graph Protocol endpoints.

Usage

import { getSubgraphEndpoint } from '@ethereum-tag-service/subgraph-endpoints'
 
const endpoint = getSubgraphEndpoint(84532)
// @log: Output: "https://api.studio.thegraph.com/query/87165/ets-base-sepolia/version/latest"
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2307. Expected: // @errors: 2307 Compiler Errors: index.ts [2307] 36 - Cannot find module '@ethereum-tag-service/subgraph-endpoints' or its corresponding type declarations.

Returns

string

The subgraph endpoint URL for the specified chain.

Parameters

chainId

  • Type: number
  • Description: Numerical identifier for the blockchain network

Examples

import { getSubgraphEndpoint } from '@ethereum-tag-service/subgraph-endpoints'
 
// Local development
const localEndpoint = getSubgraphEndpoint(31337) 
// @log: Output: "http://localhost:8000/subgraphs/name/ets-local"
 
// Base Sepolia
const baseEndpoint = getSubgraphEndpoint(84532) 
// @log: Output: "https://api.studio.thegraph.com/query/87165/ets-base-sepolia/version/latest"
## Errors were thrown in the sample, but not included in an error tag These errors were not marked as being expected: 2307. Expected: // @errors: 2307 Compiler Errors: index.ts [2307] 36 - Cannot find module '@ethereum-tag-service/subgraph-endpoints' or its corresponding type declarations.

Throws

Throws an error if no endpoint is found for the provided chainId.