eth_tx_codec
Encode signed Ethereum transaction fields into a raw tx, or decode a raw tx to extract fields, type, hash, and sender address. Supports legacy, EIP-2930, EIP-1559, and EIP-4844 formats.
Instructions
Serialize signed tx fields into a raw transaction, or decode a raw tx.
action=encode (needs fields) serializes the supplied, already-signed fields
(it does not sign) -> {type, raw:'0x...', hash}. fields is an object; the
type is taken from a type key or inferred from which fields are present
(maxFeePerGas -> 1559, blobVersionedHashes -> 4844, accessList -> 2930, else
legacy). Numbers accept int / decimal / 0x-hex; to/data are 0x-hex.
action=decode (needs data, a 0x-hex raw tx) -> {type, fields, hash, from},
recovering from from the signature; numeric fields come back as decimal
strings, addresses EIP-55 checksummed.
Example: eth_tx_codec("encode", fields={"nonce":0,"gasPrice":"0x09184e72a000", "gasLimit":"0x2710","to":"0x00..00","value":0,"data":"0x"}) -> type=0, raw="0xe5808609184e72a00082271094...808080".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | 'encode' signed fields into a raw tx, or 'decode' a raw tx. | |
| data | No | 0x-prefixed raw transaction bytes to decode (required for action=decode): a legacy RLP list or an EIP-2718 typed envelope. | |
| fields | No | Already-signed tx fields object (required for action=encode); does NOT sign. The type comes from a `type` key or is inferred (maxFeePerGas->1559, blobVersionedHashes->4844, accessList->2930, else legacy). Numbers accept int/decimal/0x-hex; `to`/`data` are 0x-hex. A stringified JSON object is accepted. |