Skip to content

xmtp/token-exporter

🪙 Token Exporter

A lightweight, high-performance Prometheus exporter that monitors ERC-20 token balances and gas (native token) balances across multiple EVM-compatible chains.

The exporter:

  • polls one or more wallet addresses
  • queries all configured ERC-20 tokens per chain
  • fetches gas/native-asset balances
  • exposes all results as Prometheus metrics
  • supports custom RPC providers (Alchemy by default)

🚀 Features

  • Multi-chain support (Base, Base Sepolia, XMTP Ropsten, etc.)
  • ERC-20 token balance monitoring
  • Gas/native token monitoring
  • Prometheus-native metrics

📦 Installation

git clone https://github.com/xmtp/tokenexporter
cd tokenexporter
go build ./cmd/tokenexporter

Or run it directly:

go run ./cmd/tokenexporter

⚙️ Configuration

1. Token list (tokens-list.json)

Example:

{
    "chains": [
    {
        "name": "base",
        "chainid": 84532,
        "root": "base-sepolia.g.alchemy.com",
        "gas": { "decimals": 18 },
        "tokens": [
            {
            "address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
            "symbol": "USDC",
            "decimal": 6
            }
        ]
    }
    ]
}

2. Addresses (addresses.txt)

   alice:0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
   bob:0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

Each line is: name:0xAddress

3. Environment variables

export APIKEY=your-alchemy-key export PORT=9102

🚦 Running the Exporter

Basic usage ./tokenexporter --apikey YOUR_KEY

Full CLI

./tokenexporter \
--apikey <alchemy-key> \
--port 9102 \
--addresses ./addresses.txt \
--tokens ./tokens-list.json

📊 Prometheus Metrics

The exporter exposes only custom metrics thanks to a custom Prometheus registry (no Go runtime metrics).

ERC-20 token balance

token_balance{
name="alice",
symbol="USDC",
contract="0x....",
address="0x....",
chain="base"
} 123.45

Native gas balance

gas_balance{
name="alice",
address="0x....",
chain="base"
} 0.0023

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages