Skip to main content
The quickest path to a working h402 integration is a thin gateway that sits in front of your HTTP service. This guide shows how to implement both client and server components using the @bit-gpt/h402 package.

Client and Server quickstart

1

Installation

2

Server implementation (to h402 gate your resources)

Express code

Explore the Express server implementation for h402 integration.

All examples

Browse all h402 integration examples available in our repository.
3

Client implementation (to interact with h402-gated servers)

Axios client code

Discover how to implement the Axios client for h402 integration.

All examples

Browse all h402 integration examples available in our repository.
Client.ts

Key Points

  • The resource server remains completely stateless - all necessary information is encoded in the payment header
  • No hidden session state or database required
  • Payment verification is deterministic and based on cryptographic proofs
  • The same pattern works for any HTTP service, from API endpoints to static files
  • Support for multiple payment networks through the same interface
For production deployments, consider:
  • Adding proper error handling
  • Implementing retry logic
  • Setting up monitoring and logging
  • Using a production-grade facilitator (or use ours https://facilitator.bitgpt.xyz/)