Programming
Generating contract bindings with abi-typegen

I was building a new project with Foundry and Forge and needed to generate typed bindings for the application using my contracts. I wanted something to take the place of TypeChain that fit the Foundry workflow, without needing Node.js just to generate the code.
I built abi-typegen in Rust to do that. It reads the ABI from compiled Solidity artifacts and generates the types and SDK helpers an application needs to use the contract. The first goal was to get the bindings I needed, quickly. Once the core was working, adding other output formats opened it up to a much wider set of applications.
Starting with Foundry
The ABI describes a contract's functions, arguments, return values, events and errors. That information is already in the artifacts Forge produces. Generating application code from those files avoids maintaining another description of the same contract by hand.
Install the generator, compile your contracts, then choose the output your application uses. This example generates bindings for viem:
cargo install abi-typegen
forge build
abi-typegen generate --target viemThe default output directory is src/generated. Add viem to the application that imports those files. The generator runs locally without an RPC connection; the application supplies its client, contract address and wallet when it uses the generated code.
A faster generation step
Speed was one of the reasons I wrote it in Rust. I wanted a native executable that could run after a build without adding much overhead.
When I introduced abi-typegen, I reported roughly 30 times faster generation than TypeChain in the launch benchmark. That was a measurement of those workflows. The contracts, selected output and surrounding build steps affect the result, so it is useful to compare the workflow you actually run. The comparison guide explains the benchmark setup and differences in generated APIs.
Replacing TypeChain in my project also meant updating the application imports. The generated helpers follow the selected SDK, and do not reproduce every TypeChain factory or class.
Beyond the original bindings
The first release already covered eight languages. Since then I have expanded the generator to 28 targets across 21 languages. The commands and target support described here reflect version 0.8.0.
One set of contracts can be used by several applications. A frontend might need viem or wagmi bindings, while an indexer uses Python, Go or Rust. Generate several targets together and each gets its own output directory:
abi-typegen generate --target viem,python,rustThe same approach works for a native mobile app using Swift, Kotlin or Dart. Game projects can use C# with the Unity adapter, GDScript with Godot, or C++ with Unreal. Each integration has its own setup and supported operations, documented in the native binding guide.
Some formats serve a different purpose. The q/kdb+ target generates event table schemas and decoders for an analytics pipeline. Solidity output produces interfaces, while Zod output provides validation schemas. Having a shared ABI parser made it possible to support these uses without building a separate generator for each one.
Keeping the bindings up to date
The bindings need to change when the contract does. During development, watch mode regenerates them as compiled artifacts change:
abi-typegen watchForge still needs to compile Solidity edits first. In CI, build the contracts and check that the generated files are current:
forge build
abi-typegen generate --target viem --checkThe check exits unsuccessfully if the output is stale and leaves the files unchanged. For Hardhat projects, the plugin can generate bindings during compilation. You can also import a local ABI or fetch a verified one from an Etherscan-compatible explorer.
abi-typegen started with the bindings I needed for one Foundry project. The common input was the useful part to build around. Once the ABI is parsed, the same contract information can be turned into code for the other applications that need it.
The library page has more examples, and the README covers installation and the available targets. The tool is published on crates.io and npm under the MIT license.