LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

abigen

Ethereum smart contract Go binding generator

TLDR

Generate Go bindings from a Solidity ABI
$ abigen --abi [contract.abi] --pkg [packagename] --out [contract.go]
copy
Generate bindings from a compiled contract
$ abigen --bin [contract.bin] --abi [contract.abi] --pkg [packagename] --out [contract.go]
copy
Generate from Solidity source directly
$ abigen --sol [contract.sol] --pkg [packagename] --out [contract.go]
copy
Specify a custom struct type name
$ abigen --abi [contract.abi] --pkg [packagename] --type [MyContract] --out [contract.go]
copy

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 for generated bindings (default: go).
--solc path
Solidity compiler path when using --sol.
--combined-json file
Path to the combined-json output from solc compiler.
--alias aliases
Comma-separated list of identifier aliases (original=replacement).

INSTALL

sudo apk add geth-tools
copy

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.

SEE ALSO

solc(1), geth(1), cast(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid