Reference · Web3 with Go & Polygon
Everything you retype every session, on one printable page.
80002 — if client.ChainID(ctx) prints anything else, you
dialed the wrong network.https://rpc-amoy.polygon.technology/ (official public endpoint).POL (worthless, faucet-supplied).wallet.key).
Gitignored, testnet-only, never holds real funds.connect + sanity-check
client, err := ethclient.Dial("https://rpc-amoy.polygon.technology/")
// client.ChainID(ctx) -> *big.Int, must be 80002
// client.BlockNumber(ctx) -> uint64, climbs every ~2s
read a balance (wei)
addr := common.HexToAddress("0x…")
wei, err := client.BalanceAt(ctx, addr, nil) // nil = latest block
big.Int survival rules
a.Cmp(b) // -1 / 0 / 1 — the ONLY way to compare (== compares pointers)
a.Sign() // -1 / 0 / 1 — quick zero-check
sum := new(big.Int).Add(a, b) // results write into the receiver
// money math: integer wei only; big.Float ONLY to format for display
wei ↔ POL
1 POL = 1_000_000_000_000_000_000 wei (10^18)
0.01 POL = 10_000_000_000_000_000 wei (10^16)
max int64 ≈ 9.22 POL in wei — hence *big.Int everywhere
Course glossary · Ethereum Development with Go · ethclient GoDoc