Base
Bereit, das in der Produktion aufzurufen?
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
Base
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
go-ethereum (geth) is the official Go implementation of the Ethereum protocol and the most complete, up-to-date EVM library available to Go developers. Because Base is an OP Stack rollup that is EVM-equivalent and uses ETH for gas, geth's ethclient connects to Base exactly as it would to Ethereum mainnet — just point it at https://base.therpc.io/YOUR_API_KEY and work against chain ID 8453. Install it with go get github.com/ethereum/go-ethereum. It is maintained by the Ethereum Foundation.
go-ethereum is the official Go client, maintained by the Ethereum Foundation, and it gives Go developers building on Base the most complete and up-to-date EVM implementation in the language — the same library that powers production node operators.
Connect to Base by calling ethclient.Dial("https://base.therpc.io/YOUR_API_KEY"), which returns a client you can use for every eth_* call. Wrap that client in your own struct, as shown below, so the connection is created once and your balance, transaction, and contract helpers stay organized and easy to unit-test with a mock.
For type-safe contract access on Base, run abigen to generate Go bindings from a Solidity ABI — this gives you compile-checked methods instead of stringly-typed calls. Under the hood a bind.BoundContract wraps the parsed ABI and exposes Call for read-only views and Transact for state-changing writes that spend ETH for gas. You can pull the ABI of any verified Base contract from https://basescan.org.
SubscribeNewHead and other live subscriptions need a WebSocket connection — the HTTP endpoint cannot push updates, so for streaming Base block headers dial a wss:// URL instead. Run the subscription in a goroutine and use a select to handle both incoming headers and the subscription's error channel, so a dropped connection is caught rather than silently stalling. With Base producing a block roughly every 2 seconds, expect a steady stream of new heads.
Base balances and amounts are wei values up to 18 decimals, far beyond what float64 can hold without rounding error, so do all wei arithmetic with big.Int and big.Float. The helpers below convert between wei and ETH and validate addresses; reach for float64 only at the very end, for display.