npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@graphprotocol/client-x402

v1.0.0

Published

x402 payment protocol support for graph-client

Readme

@graphprotocol/client-x402

Query The Graph's gateway with automatic payment handling using the x402 protocol, no API key required!

Installation

npm install @graphprotocol/client-x402

Environments

| Environment | Gateway endpoint | Payment network | | ------------ | ----------------------------------------------- | --------------- | | production | https://gateway.thegraph.com/api/x402 | base | | testnet | https://testnet.gateway.thegraph.com/api/x402 | base-sepolia |

Usage

Three ways to use this package, from simplest to most complete:

1. CLI

For quick queries, testing, or shell scripts. No code required.

export X402_PRIVATE_KEY=0xabc123...

graphclient-x402 "{ pairs(first: 5) { id } }" \
  --endpoint https://gateway.thegraph.com/api/x402/subgraphs/id/<SUBGRAPH_ID> \
  --chain base

2. Programmatic

For scripts, bots, or simple integrations. No build step, no types.

import { createGraphQuery } from '@graphprotocol/client-x402'

const query = createGraphQuery({
  endpoint: 'https://gateway.thegraph.com/api/x402/subgraphs/id/<SUBGRAPH_ID>',
  chain: 'base',
})

const result = await query('{ pairs(first: 5) { id } }')
console.log(result.data)

3. Typed SDK

For applications that want full type safety. Uses the @graphprotocol/client-cli build workflow to generate a typed SDK from your schema.

Install:

npm install @graphprotocol/client-cli @graphprotocol/client-x402

Configure .graphclientrc.yml:

customFetch: '@graphprotocol/client-x402'

sources:
  - name: uniswap
    handler:
      graphql:
        endpoint: https://gateway.thegraph.com/api/x402/subgraphs/id/<SUBGRAPH_ID>

documents:
  - ./src/queries/*.graphql

Define your queries in src/queries/pairs.graphql:

query GetPairs($first: Int!) {
  pairs(first: $first) {
    id
    token0 {
      symbol
    }
    token1 {
      symbol
    }
  }
}

Build:

export X402_PRIVATE_KEY=0xabc123...
export X402_CHAIN=base
graphclient build
rm .graphclient/package.json  # Required: mesh generates broken ESM exports

Use with full type safety:

import { execute, GetPairsDocument } from './.graphclient'

const result = await execute(GetPairsDocument, { first: 5 })
//    ^ fully typed based on your schema and query

Configuration

All configuration is via environment variables:

export X402_PRIVATE_KEY=0x...        # Required: private key for signing payments
export X402_CHAIN=base               # Optional: "base" (default) or "base-sepolia"

Private Key

Required for signing payment permits. Can also be provided via:

  • privateKey option in createGraphQuery() (Mode 2)
  • config.x402PrivateKey in execute() context (Mode 3)

Chain

The payment chain can also be specified via:

  • chain option in createGraphQuery() (Mode 2)
  • --chain flag in CLI (Mode 1)