scanner

package module
v0.0.0-...-4427c07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: AGPL-3.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ChainScanner

ChainScanner

Watch blockchain addresses and receive their transactions over WebSocket, gRPC or HTTP.

English · 简体中文 · Tiếng Việt · Español · Русский

Go 1.25+  ·  AGPL-3.0  ·  18 networks

Quick start  ·  Networks  ·  API reference


Bitcoin mainnet endpoints and configuration

Why we built ChainScanner

While developing GM Wallet and GMPay, we kept running into the same problem. The wallet needed to know which balances to refresh, and the payment service needed to know when a receiving address had new activity. Polling RPC endpoints for each address in each app spent quota twice when both apps were looking for the same transaction.

ChainScanner gives all subscribers on a network a shared block scan. Each service receives transactions that match its addresses and acknowledges them independently. A wallet can refresh just the affected balances, while GMPay can verify the corresponding orders. In an Ethereum mainnet replay, reading the same four blocks took 11 upstream RPC calls when watching one address, when watching 100 addresses, and when two services watched those same 100 addresses.

Each application manages its own business logic, order status and wallet balances. ChainScanner provides shared infrastructure for address subscriptions, block scanning and event delivery.

[!IMPORTANT] Hash lookup prefers fallback nodes. An ordinary node that supplied the block is excluded. A fallback that supplied the block can verify it while it still has the fallback role. Compare fallback providers

Use cases

  • On-chain checkout. The EPUSDT integration subscribes to deposit addresses, marks a matching order as confirming and checks the transaction through the strict lookup before crediting it.
  • Telegram wallet bot idea. Subscribe to a personal address, record each delivery, then send a message identifying an incoming or outgoing transfer.
  • Treasury reconciliation idea. Watch operational wallets once and deliver the same activity to accounting and alerting as separate consumers, each with its own acknowledgement.

Subscribe to an address

With a local server running, use the consumer token from the quick start as $TOKEN. Replace the example with your Base address. This request sets the consumer’s entire watch list.

curl -fsS -X PUT http://127.0.0.1:9081/v1/subscriptions \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '[{
    "network": "base",
    "address": "0x1111111111111111111111111111111111111111"
  }]'

The response includes from_height, the first block covered. Receive and acknowledge transactions

Failed ranges rotate across eligible fallback nodes. Register each node separately. API

BASE=http://127.0.0.1:9081
ADMIN_TOKEN=$(jq -er '.admin_token' chainscanner.json)
curl -fsS -X POST "$BASE/v1/admin/nodes/fallback" \
  -H "Authorization: Bearer $ADMIN_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"network":"base","protocol":"http","url":"https://paid-rpc.example.org","api_key":"YOUR_PROVIDER_KEY"}'

Fallback providers

Provider shortlist, checked 2026-11-21. Choose independently. ChainScanner does not guarantee availability, data accuracy or pricing. Credits, CU and RU depend on the RPC method and are not interchangeable. Check network, history and protocol support for both endpoints.

Website Founded or first public release Free allowance
Ankr 2017 · distributed node infrastructure 200M API credits/month with a Freemium account
Infura 2016 · Consensys Ethereum and IPFS infrastructure 3M credits/day on Core, per the pricing documentation
PublicNode 2018 · operator Allnodes began offering node infrastructure Shared public RPC, no fixed per-user monthly allowance published
QuickNode 2017 · managed multichain RPC and data streams 10M API credits for a 30-day trial
Alchemy 2017 · blockchain developer APIs and node access 30M CU/month
BlockPI 2022-10-25 · distributed RPC network alpha launch 50M RU/month for registered users
dRPC 2023-03 · decentralized RPC gateway opened to the public 50M CU per 30 days

A note from the maintainers

If your project uses ChainScanner or builds on its design, we’d appreciate a link in your README. Your recommendation helps other developers find us and means a lot to our team. We’re glad we could help. Thank you for using ChainScanner!

Reference: [ChainScanner](https://github.com/GMWalletApp/ChainScanner)

Thanks to imToken and Bitget Wallet for public RPC resources, and to ChainList, OpenChainBench and CompareNodes for their public node directories. Thank you to everyone who uses and trusts ChainScanner.

Documentation

Overview

Package scanner follows blockchain activity and delivers it to address subscribers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNetworkNotConfigured = engine.ErrNetworkNotConfigured
	ErrCursorNotReady       = feed.ErrCursorNotReady
)

Functions

func Canonical

func Canonical(n, a string) (string, error)

Canonical normalizes an address for comparison on the given network.

func ConfigureNetworks

func ConfigureNetworks(store *Store, networks map[string]Network, head func(context.Context, string) (int64, error))

ConfigureNetworks supplies an embedded store with raw chain heads for subscription boundaries. Call before serving requests. The standalone node registry configures this automatically.

func ConnectTONPeer

func ConnectTONPeer(ctx context.Context, pool *liteclient.ConnectionPool, raw string) error

ConnectTONPeer opens a mainnet-verified ADNL connection for a selected registry endpoint.

func EVMChainID

func EVMChainID(name string) int64

EVMChainID returns the configured EVM chain ID, or zero for other networks.

func Handler

func Handler(s *Store, consumers map[string]string) (http.Handler, error)

Handler serves the consumer API using a separate bearer token per consumer.

func IsEVM

func IsEVM(name string) bool

IsEVM reports whether the network uses the EVM adapter.

func ManagementProtocols

func ManagementProtocols() map[string][]string

ManagementProtocols lists admin-selectable transports, including height and strict lookup endpoints.

func NativeAsset

func NativeAsset(name string) string

NativeAsset returns the native top-level transfer asset when supported.

func NeedsHistory

func NeedsHistory(network, protocol string) bool

NeedsHistory reports whether a transport requires a companion history endpoint.

func PaymentEvidence

func PaymentEvidence(network string, raw json.RawMessage) (json.RawMessage, error)

PaymentEvidence normalizes chain-native hash lookup data for a payment consumer.

func Protocols

func Protocols(network string) []string

Protocols lists the node protocols accepted for a network, in preference order.

func Supported

func Supported(name string) bool

Supported reports whether the scanner can read transactions on the network.

func TONReadSlice

func TONReadSlice(ctx context.Context, n Network, master *ton.BlockIDExt, contract *address.Address, method string, arg *cell.Cell) (*cell.Slice, error)

TONReadSlice runs a TON contract getter and returns its result as a slice.

func ValidateEndpoint

func ValidateEndpoint(n Network) error

ValidateEndpoint checks a primary endpoint before selecting a history node.

func ValidateNetwork

func ValidateNetwork(n Network) error

ValidateNetwork validates a complete network configuration.

func Wakeups

func Wakeups(s Source) <-chan struct{}

Wakeups returns a source’s optional channel of new head notifications.

Types

type Activity

type Activity = chains.Activity

func SuiTransaction

func SuiTransaction(ctx context.Context, n Network, digest string) (Activity, error)

SuiTransaction reads a Sui transaction by digest.

type AssetEventLayout

type AssetEventLayout = chains.AssetEventLayout

type AssetEventRules

type AssetEventRules = chains.AssetEventRules

type Client

type Client = feed.Client

type Delivery

type Delivery = feed.Delivery

type Evidence

type Evidence = chains.Evidence

type Feed

type Feed = feed.Feed

type LookupAttempt

type LookupAttempt = nodes.LookupAttempt

type ManagementCapabilities

type ManagementCapabilities = nodes.ManagementCapabilities

type MigrationManifest

type MigrationManifest = nodes.MigrationManifest

type Network

type Network = chains.Network

type Node

type Node = nodes.Node

type NodeEndpoint

type NodeEndpoint = nodes.NodeEndpoint

type NodeOptions

type NodeOptions = nodes.NodeOptions

type NodeRegistry

type NodeRegistry = nodes.NodeRegistry

func NewNodeRegistry

func NewNodeRegistry(ctx context.Context, s *Store, networks []Network) (*NodeRegistry, error)

NewNodeRegistry loads built-in, configured and persisted nodes.

func NewNodeRegistryWithBlockedHosts

func NewNodeRegistryWithBlockedHosts(ctx context.Context, s *Store, networks []Network, hosts []string) (*NodeRegistry, error)

NewNodeRegistryWithBlockedHosts also excludes matching endpoint hosts and their subdomains.

type NodeRoute

type NodeRoute = nodes.Route

type Reconciler

type Reconciler = feed.Reconciler

type Reconciliation

type Reconciliation = feed.Reconciliation

type Registration

type Registration = feed.Registration

type RouteInventory

type RouteInventory = nodes.RouteInventory

type Source

type Source = chains.Source

func NewSource

func NewSource(ctx context.Context, n Network) (Source, error)

NewSource opens the configured node using the network’s selected protocol.

type SourcePool

type SourcePool = nodes.SourcePool

func NewSourcePool

func NewSourcePool(ctx context.Context, network string) *SourcePool

NewSourcePool distributes ranges across nodes of a single concrete network.

type Store

type Store = engine.Store

func Open

func Open(path string) (*Store, error)

Open opens the scanner's persistent SQLite store.

type SubscriptionReceipt

type SubscriptionReceipt = feed.SubscriptionReceipt

type TONData

type TONData = chains.TONData

type Termination

type Termination = feed.Termination

type Watch

type Watch = feed.Watch

Directories

Path Synopsis
api
cmd
chainscanner command
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL