Ethereum ABI Encoder & Decoder

Build Ethereum contract calldata from a canonical function signature and JSON arguments, decode transaction input hex, parse event logs from topics and data, or encode raw ABI parameters without a selector. Compare selectors with Keccak-256, copy full calldata for cast and ethers, and debug ERC-20 transfers locally — nothing uploaded.

Mode

Quick examples:

Canonical Solidity form without spaces or names: transfer(address,uint256). You can prefix with function.

One JSON array matching parameter types. Addresses and bytes as 0x strings; integers as numbers or strings (e.g. "1000000000000000000"). Tuples and arrays nest as JSON.

Result

Function selector

0xa9059cbb

Encoded arguments

0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a7640000

Full calldata

0xa9059cbb00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a7640000

Encoding and decoding run in your browser with viem. Do not paste private keys or production secrets.

What ABI encoding does on Ethereum

When you call a smart contract, your wallet sends hex calldata: a four-byte function selector followed by ABI-encoded arguments. The selector is the first four bytes of Keccak-256 of the canonical signature string — for example `transfer(address,uint256)` becomes `0xa9059cbb`. Arguments are packed according to the Solidity ABI spec: 32-byte words, dynamic types offset-encoded, structs and arrays nested as defined in your interface. Decoding reverses that process for debugging, analytics, and security review. Event logs split data differently: topic[0] is the event signature hash, indexed parameters fill further topics, and non-indexed fields sit in the log data payload. This tool runs encode and decode locally with viem so you can verify calldata before a mainnet transaction, inspect mempool calls, or teach ABI layout without pasting secrets into a random pastebin.

How calldata is built

Canonical function signature = `name(type1,type2,…)` with no spaces, no parameter names, only types (use `uint256` not `uint`, `int256` not `int` in signatures). selector = first 4 bytes of keccak256(UTF-8 signature). encodedArgs = ABI encode of the parameter tuple. fullCalldata = selector ‖ encodedArgs (hex). For raw parameter encoding without a selector, use comma-separated types with `encodeAbiParameters`. Decoding uses the same signature to split the selector and unpack words. Events use `event Name(types…)`; topic[0] = keccak256(event signature); indexed args are ABI-encoded in topics[1..]; non-indexed args are in `data`. Compare outputs with `cast calldata`, `cast abi-decode`, `ethers.Interface`, or Foundry scripts — they must match for the same canonical string and values.

Worked ABI examples

  1. ERC-20 transfer calldata

    Signature transfer(address,uint256), args ["0x000…001", "1000000000000000000"] (1 token with 18 decimals).

    Selector 0xa9059cbb + 32-byte padded address + 32-byte uint256 amount.

    Paste the full hex into the Decode tab to recover the recipient and amount — useful when auditing wallet transactions.

  2. ERC-20 Transfer event log

    Event Transfer(address,address,uint256) with indexed from and to in topics[1] and topics[2], value in data.

    topic[0] is the event selector; decode merges indexed and non-indexed fields into named args.

    Block explorers show the same breakdown — this page helps when you only have raw RPC log JSON.

  3. approve unlimited allowance

    approve(address,uint256) with max uint256.

    Selector 0x095ea7b3 with spender address and 2^256−1.

    Common DeFi flow — encode here to double-check spender and amount before signing.

  4. balanceOf view call

    balanceOf(address) with a holder address.

    Same calldata format even for read-only eth_call — no ETH sent, only ABI payload.

    Useful for scripting eth_call payloads without opening a full IDE.

ABI encoder & decoder FAQ

What is Ethereum ABI encoding?
It is the standard layout Solidity uses to serialize function arguments and return values into 32-byte words. Wallets prepend a four-byte selector so the EVM knows which function to run.
How do I encode a contract function call?
Enter the canonical signature and a JSON array of arguments. The tool outputs the selector, encoded arguments, and full calldata you can paste into cast, Hardhat, or a hardware wallet debug screen.
How do I decode transaction input data?
Paste the hex calldata from a block explorer and the function signature you expect. Decoded JSON shows each parameter — if it fails, the signature or data may be wrong or the call may use a proxy fallback.
Can I decode event logs?
Yes. Switch to Decode event log, paste the event signature, topics array, and data field from an eth_getLogs response.
Is my calldata sent to a server?
No. viem runs entirely in your browser. Still avoid pasting private keys; calldata can contain sensitive business logic.
Why must signatures omit spaces?
Ethereum tooling hashes the exact string `transfer(address,uint256)`. Spaces or parameter names change the selector and break decode.
How is this different from the Keccak-256 tool?
Keccak gives you hashes and selectors. This tool also ABI-encodes and decodes full argument tuples and event logs.
Does it support tuples, arrays, and bytes?
Yes — express nested values as JSON arrays and objects matching your Solidity types. Complex structs may need exact field order as in the ABI.

Related developer tools

How it works

  • Choose encode function call, decode calldata, or decode an event log.
  • Enter the canonical Solidity signature and JSON arguments, or paste hex calldata / RPC log fields.
  • Copy the selector, encoded data, or decoded JSON — computed locally with viem.

For education only — not financial advice. Past performance does not guarantee future results.