Skip to content

enviodev/hypersync-client-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

109 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hypersync-client-go

Tests Status Security Status Coverage Status Discord

Go client for Envio's HyperSync. Provides a native Go interface for accessing HyperSync, HyperRPC, and HyperCURL.

Note: This client is community maintained and marked as work-in-progress. For production use, consider the officially supported clients: Node.js, Python, or Rust.

What is HyperSync?

HyperSync is Envio's high-performance blockchain data retrieval layer. It is a purpose-built alternative to JSON-RPC endpoints, offering up to 2000x faster data access across 70+ EVM-compatible networks and Fuel.

HyperSync lets you query logs, transactions, blocks, and traces with flexible filtering and field selection, returning only the data you need.

If you need a full indexing framework on top of HyperSync with GraphQL APIs and schema management, see HyperIndex.

Features

  • Native Go interface: Idiomatic Go API for accessing HyperSync
  • Blocks, logs, transactions, traces: Query all major blockchain data types
  • HyperRPC support: Drop-in JSON-RPC compatible endpoint access
  • Streaming: Process large datasets with built-in pagination
  • Event decoding: Decode ERC-721 and other ABI-encoded events
  • 70+ networks: Access any HyperSync-supported network

Installation

go get github.com/enviodev/hypersync-client-go

API Token

An API token is required to use HyperSync. Get your token here, then set it as an environment variable:

export ENVIO_API_TOKEN="your-token-here"

Quick Start

import (
    hypersyncgo "github.com/enviodev/hypersync-client-go"
    "github.com/enviodev/hypersync-client-go/options"
)

node := options.Node{
    Endpoint:    "https://eth.hypersync.xyz",
    RpcEndpoint: "https://eth.rpc.hypersync.xyz",
    ApiToken:    os.Getenv("ENVIO_API_TOKEN"),
}

client, err := hypersyncgo.NewClient(ctx, node)
if err != nil {
    log.Fatal(err)
}

See the examples directory for complete usage including block ranges, log queries, transaction queries, trace queries, and decoded ERC-721 events.

Connecting to Different Networks

Change the Endpoint to connect to any supported network:

// Arbitrum
node := options.Node{
    Endpoint: "https://arbitrum.hypersync.xyz",
    ApiToken: os.Getenv("ENVIO_API_TOKEN"),
}

// Base
node := options.Node{
    Endpoint: "https://base.hypersync.xyz",
    ApiToken: os.Getenv("ENVIO_API_TOKEN"),
}

See the full list of supported networks and URLs.

Running Examples

# Set your API token first
export ENVIO_API_TOKEN="your-token-here"

# Run an example
go run ./examples/blocks_in_range.go
go run ./examples/logs_in_range.go
go run ./examples/transactions_in_range.go
go run ./examples/traces_in_range.go
go run ./examples/erc721_events_decoded.go

Example files use //go:build ignore so they are not built with the main module.

What you can build

The Go client is a good fit for teams building blockchain tooling in Go that need fast, direct access to on-chain data:

  • Blockchain data pipelines: Query logs, transactions, blocks, and traces at scale without RPC bottlenecks
  • Block explorers: Power responsive interfaces with real-time data access across 70+ chains
  • Monitoring tools: Track wallet activity and contract events in near real-time
  • Analytics tools: Scan entire chain histories in seconds instead of hours
  • Go-native integrations: Access HyperSync and HyperRPC from existing Go services without switching language

Testing

# Load API token from .env file (recommended for local dev)
set -a && source .env && set +a

# Run all tests
go test ./... -v

Unit tests that do not call the real API work without a token. Tests that call HyperSync will return 401 without a valid token.

Documentation

FAQ

How does this compare to using standard Go JSON-RPC clients? HyperSync retrieves data up to 2000x faster than traditional JSON-RPC. It is designed for bulk historical data access across multiple block ranges.

Do I need an API token? Yes. The token must be set on each options.Node as ApiToken. Get one here.

Which networks are supported? 70+ EVM-compatible networks and Fuel. See the full list.

Is this production ready? This client is community maintained and marked as work-in-progress. Test thoroughly before using in production. The officially supported clients are Node.js, Python, and Rust.

What is HyperRPC? HyperRPC is Envio's fast read-only RPC endpoint designed for data-intensive tasks. It is a drop-in JSON-RPC compatible alternative to traditional nodes. Behind the scenes, HyperRPC uses HyperSync to fulfill requests. For most use cases Envio recommends using HyperSync directly, as it provides greater speed and query flexibility. HyperRPC docs →

What is the difference between HyperSync and HyperIndex? HyperSync is the raw data access layer. Use it when you need direct access to blockchain data in your own pipeline. HyperIndex is the full indexing framework built on top of HyperSync, with schema management, event handlers, and a GraphQL API.

Support

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors