Skip to main content
Glama
laszlopere

mcp-bytesmith

eth_tx_codec

Serialize tx fields into a raw transaction, or decode a raw tx.

Instructions

Serialize tx fields into a raw transaction, or decode a raw tx.

action=encode (needs fields) serializes the supplied fields (it does not sign) -> {type, raw:'0x...', hash, signing_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, signing_hash, from}, recovering from from the signature; numeric fields come back as decimal strings, addresses EIP-55 checksummed.

signing_hash is the digest the sender signs: keccak256 of the payload without the signature (typed: type_byte || rlp(fields minus yParity/r/s); legacy EIP-155: rlp(fields[:6] + [chainId, 0, 0]); pre-EIP-155: rlp(fields[:6])). hash is the tx hash, which covers the signature too, so it is only meaningful once signed. To sign: encode the unsigned fields, sign signing_hash with eth_sign, then encode again with r, s and yParity — legacy instead takes v = chainId*2 + 35 + yParity (27 + yParity pre-EIP-155).

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

TableJSON Schema
NameRequiredDescriptionDefault
dataNo0x-prefixed raw transaction bytes to decode (required for action=decode): a legacy RLP list or an EIP-2718 typed envelope.
actionYes'encode' signed fields into a raw tx, or 'decode' a raw tx.
fieldsNoTx fields object (required for action=encode); does NOT sign. Omit v/yParity/r/s for an unsigned tx, whose `signing_hash` is what to sign; a legacy tx's `chainId` makes it EIP-155 (it is carried in v, so a signed legacy v must encode it). 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.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.4.1
    • changedInput schema / properties / fields / description
      Previous value: -"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."New value: +"Tx fields object (required for action=encode); does NOT sign. Omit v/yParity/r/s for an unsigned tx, whose `signing_hash` is what to sign; a legacy tx's `chainId` makes it EIP-155 (it is carried in v, so a signed legacy v must encode it). 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."
  2. Changed3 schema fields changedv0.3.0
    • addedInput schema / properties / action / description
      Added value: +"'encode' signed fields into a raw tx, or 'decode' a raw tx."
    • addedInput schema / properties / data / description
      Added value: +"0x-prefixed raw transaction bytes to decode (required for action=decode): a legacy RLP list or an EIP-2718 typed envelope."
    • addedInput schema / properties / fields / description
      Added value: +"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."
  3. First observedv0.0.1

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description carries the full burden and does so well: it discloses that encode does NOT sign, that `hash` is only meaningful once signed, how `signing_hash` is derived per tx type (typed, EIP-155, pre-EIP-155), and the exact v-computation for legacy signatures. This is exactly the behavioral context an agent needs to avoid producing an invalid transaction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the two actions and their required inputs, with a worked example at the end. It is dense but largely earns its length, though the type-inference mapping and numeric-format notes are restated from the schema, adding some redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by specifying the return shape for both actions (type/raw/hash/signing_hash for encode; type/fields/hash/signing_hash/from for decode) plus formatting details like decimal strings and EIP-55 checksumming. Nothing an agent needs to call this correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3, but the description goes beyond the schema by tying parameters together: the type-inference mapping, the rule that omitting v/yParity/r/s yields an unsigned tx, and that a legacy `chainId` is carried in v. That relational guidance is not expressible in per-field schema text.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource pair ('Serialize tx fields into a raw transaction, or decode a raw tx') and immediately splits the two modes by action. An agent can distinguish this from rlp_codec, abi_codec, or eth_calldata from the first sentence alone.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Clearly states which inputs each action requires (encode needs `fields`, decode needs `data`) and walks through the encode→sign→re-encode workflow for signing. It stops short of naming alternative sibling tools (e.g. rlp_codec for raw RLP), so it is clear context without explicit exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.