Skip to main content

Ethereum ABI Encoder/Decoder

Encode Solidity values to ABI hex and decode ABI hex back to values. Supports all primitive types, arrays, and tuples.

✓ abi.encode / encodePacked ✓ All Solidity types ✓ Tuple / struct support

Encode Values

Decode ABI Hex

Encoded Output

Decoded Values

Frequently Asked Questions

What is Ethereum ABI encoding?▼

ABI (Application Binary Interface) encoding is how Ethereum represents function arguments and return values as raw bytes. It's used in calldata, event logs, and function return data. Static types are padded to 32-byte slots. Dynamic types (bytes, string, arrays) use an offset/length scheme where the static section holds a pointer to the dynamic data location.

What is the difference between abi.encode and abi.encodePacked?▼

abi.encode pads all types to 32-byte boundaries — safe and unambiguous. abi.encodePacked concatenates types without padding — smaller output but can be ambiguous (e.g., abi.encodePacked('a','bc') == abi.encodePacked('ab','c')). Never use encodePacked for signatures or hash inputs that combine dynamic types, as it can enable hash collision attacks.

How are events ABI-encoded in logs?▼

Event logs have up to 4 topics (32 bytes each) and arbitrary data. The first topic is the event selector (keccak256 of the event signature). Indexed parameters go into topics (up to 3). Non-indexed parameters go into data as ABI-encoded values. Dynamic types (string, bytes, arrays) when indexed are keccak256-hashed — you can't reverse this.

What is a struct in ABI encoding?▼

Structs are encoded as tuples in ABI. A struct with fields (uint256 a, address b) is encoded as tuple(uint256,address). The encoding follows the same rules as regular ABI — static fields are at their offsets, dynamic fields use pointer indirection. Nested structs are recursively encoded.

How do I decode a Revert error?▼

Revert with a reason string encodes as: selector for Error(string) = 0x08c379a0, followed by ABI-encoded string offset + length + data. Custom errors use their own selector + ABI-encoded arguments. You can decode a revert reason by removing the 4-byte selector and decoding the remaining data as ABI-encoded (string) or custom error types.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →