Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastabi — ABI Codec for EVM

A high-performance ABI encoder/decoder for EVM chains. No go-ethereum dependency.

Features

  • ABIv2 — all Solidity types: uint8uint256, int8int256, address, bool, bytes, bytes32, string, arrays, nested tuples
  • Zero-alloc — pooled Decoder/Encoder via sync.Pool, no heap allocations per call after warm-up
  • U256 — wraps holiman/uint256 inline (no pointer, GC-friendly), with pooling for hot paths
  • Signature parserParseFunction("transfer(address,uint256)") → name + parameter types
  • Keccak256 — 4-byte selectors from function signatures
  • Wad mathWadMul, WadDiv, WadLn for DeFi fixed-point arithmetic

Quick Start

import "github.com/cryptoddev/fastabi"

// Encode a single uint256
data := fastabi.Encode1(fastabi.TUint256(), uint64(42))

// Decode
val, _ := fastabi.Decode1(fastabi.TUint256(), data)
u := val.(*fastabi.U256)

// Pooled low-level API for hot paths
enc := fastabi.GetEncoder()
defer fastabi.PutEncoder(enc)
enc.EncodeUint64(42)
data = enc.Bytes()

Types

Constructor Solidity Go Type
TUint<N>() uint8uint256 uint64, *big.Int, *U256
TInt<N>() int8int256 int64, *big.Int
TAddress() address [20]byte, Address
TBool() bool bool
TBytes() bytes []byte
TBytes32() bytes32/bytesN [32]byte
TString() string string
TArray(elem) type[] []any
TFixedArray(elem, n) type[n] []any
TTuple(...) (a,b,c) []any

Testing

go test ./...
go test -bench=. ./...

License

MIT

About

Zero-allocation ABI encoder/decoder for EVM chains. No go-ethereum dependency.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages