abigen
Ethereum smart contract Go binding generator
TLDR
Generate Go bindings from a Solidity ABI
SYNOPSIS
abigen [--abi file] [--bin file] [--sol file] [--pkg name] [--out file] [options]
DESCRIPTION
abigen is an Ethereum tool that generates Go language bindings for interacting with smart contracts. It takes a contract's ABI (Application Binary Interface) and optionally its bytecode to produce type-safe Go code for deploying and calling contract methods.
The generated code handles ABI encoding/decoding, transaction creation, and event filtering, making it straightforward to interact with Ethereum contracts from Go applications. This eliminates the need for manual ABI manipulation and provides compile-time type checking.
PARAMETERS
--abi file
Path to the contract ABI JSON file--bin file
Path to the contract bytecode (required for deployment code generation)--sol file
Path to Solidity source file (requires solc compiler)--pkg name
Package name for the generated Go code--out file
Output file path for generated code--type name
Struct name for the contract binding (defaults to contract name)--lang language
Target language: go, java, objc--solc path
Solidity compiler path when using --sol
CAVEATS
When using --sol, the Solidity compiler (solc) must be installed and accessible. ABI changes require regenerating bindings. Complex Solidity types may produce verbose Go code. Ensure ABI and bytecode match when deploying contracts.
HISTORY
abigen was developed by the Ethereum Foundation as part of go-ethereum (geth), first appearing around 2015. It was created to provide idiomatic Go bindings for smart contracts, supporting the growing ecosystem of Go-based Ethereum tools and applications.
