tokenbalance: Index | Examples | Files | Directories

package tokenbalance

import ""

Package tokenbalance is used to fetch the latest token balance for any Ethereum address and ERC20 token. You can install this package/CLI or you can use basic HTTP GET on the public TokenBalance server.

Mainnet API Endpoint:

Example: Response: `5401731.086778292432427406`

Example: Response: “` { "token": "0xa74476443119A942dE498590Fe1f2454d7D4aC0d", "wallet": "0xda0AEd568D9A2dbDcBAFC1576fedc633d28EEE9a", "name": "Golem Network token", "symbol": "GNT", "balance": "5401731.086778292432427406", "eth_balance": "0.985735366999999973", "decimals": 18, "block": 6461672 } “`

Ropsten Testnet API Endpoint:

Rinkeby Testnet API Endpoint:

More info on:



Package Files

doc.go tokenbalance.go tokens.go types.go


var (
    Geth *ethclient.Client

    VERSION string

type Config Uses

type Config struct {
    GethLocation string
    Logs         bool

func (*Config) Connect Uses

func (c *Config) Connect() error

type TokenBalance Uses

type TokenBalance struct {
    Contract common.Address
    Wallet   common.Address
    Name     string
    Symbol   string
    Balance  *big.Int
    ETH      *big.Int
    Decimals int64
    Block    int64
    // contains filtered or unexported fields

func New Uses

func New(contract, wallet string) (*TokenBalance, error)

Create a New Token Balance request with the ERC20 contract address and a wallet address


token := "0xb64ef51c888972c908cfacf59b47c1afbc0ab8ac"
wallet := "0x9ea0c535b3eb166454c8ccbaba86850c8df3ee57"
example, _ = New(token, wallet)
fmt.Printf("This wallet has %v %v tokens", example.BalanceString(), example.Name)


This wallet has 7.282 StorjToken tokens

func (*TokenBalance) BalanceString Uses

func (tb *TokenBalance) BalanceString() string

Return the Token Balance as a string rather than a *big.Int


tokens := example.BalanceString()
fmt.Printf("This wallet has %v %v tokens", tokens, example.Name)


This wallet has 7.282 StorjToken tokens

func (*TokenBalance) ETHString Uses

func (tb *TokenBalance) ETHString() string

Return the ETH Balance as a string rather than a *big.Int


eth := example.ETHString()
fmt.Printf("This wallet has %v ETH", eth)


This wallet has 0.277525175999999985 ETH

func (*TokenBalance) ToJSON Uses

func (tb *TokenBalance) ToJSON() string

View all token information as JSON


data := example.ToJSON()


cmdPackage main inside the cmd folder contains TokenBalance binary file for your operating system

Package tokenbalance imports 12 packages (graph) and is imported by 3 packages. Updated 2019-12-03. Refresh now. Tools for package owners.