Skip to content

SagarKarmoker/erc20-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ERC20 CLI

A command-line tool for interacting with ERC20 tokens on multiple blockchain networks.

Features

  • Query ERC20 token information (name, symbol, decimals, total supply)
  • Check token balances for any address
  • Support for multiple chains: Ethereum, Polygon, BSC, Arbitrum, Optimism, and Base
  • Simple and intuitive CLI interface

Installation

Option 1: Build from source

go build -o erc20-cli .

Option 2: Build for multiple platforms

Use the included build script to create binaries for multiple platforms:

./build.sh 1.0.0

This will create binaries in the build/ directory for:

  • Linux (amd64, arm64)
  • macOS (amd64, arm64)
  • Windows (amd64)

Option 3: Download pre-built binaries

Download the appropriate binary for your platform from the Releases page.

Note: The binary you build will only work on the same operating system and architecture it was built for. For example:

  • A Linux binary won't work on macOS or Windows
  • A 64-bit binary won't work on 32-bit systems
  • An ARM binary won't work on x86 systems

To share the binary with others, either:

  1. Build it for their specific platform
  2. Share the source code and let them build it
  3. Use the build script to create binaries for all platforms

Usage

Commands

  • balance <address> - Get token balance for an address
  • info - Get all token information (name, symbol, decimals, total supply)
  • name - Get token name
  • symbol - Get token symbol
  • decimals - Get token decimals
  • total-supply - Get total token supply
  • help - Show help message

Flags

  • -chain-id <id> - Chain ID (required)
    • 1 = Ethereum
    • 137 = Polygon
    • 56 = BSC (Binance Smart Chain)
    • 42161 = Arbitrum
    • 10 = Optimism
    • 8453 = Base
  • -token <address> - Token contract address (required)

Examples

Get token balance:

./erc20-cli balance 0x1234567890123456789012345678901234567890 \
  -chain-id 1 \
  -token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48

Get all token information:

./erc20-cli info \
  -chain-id 137 \
  -token 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174

Get token name:

./erc20-cli name -chain-id 1 -token 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48

Project Structure

erc20-cli/
├── main.go                 # CLI interface
├── internal/
│   ├── rpc/
│   │   └── client.go       # RPC client for Ethereum calls
│   └── erc20/
│       └── token.go         # ERC20 token functions
└── go.mod                  # Go module dependencies

How It Works

  1. The CLI uses Ethereum RPC calls (eth_call) to interact with ERC20 token contracts
  2. Function signatures are encoded using Keccak256 hashing (first 4 bytes)
  3. Parameters are ABI-encoded and appended to the function selector
  4. Responses are decoded from hex format to human-readable values

Supported Networks

The tool uses public RPC endpoints from publicnode.com:

  • Ethereum Mainnet
  • Polygon
  • Binance Smart Chain
  • Arbitrum
  • Optimism
  • Base

License

MIT

About

A command-line tool for interacting with ERC20 tokens on multiple blockchain networks.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors