Skip to content

serializeTransaction changes EIP-7702 authorization yParity, breaking transaction round-trips #5297

Closed

Description

@sam-potter

Check existing issues

Viem Version

2.57.11

Current Behavior

Serialization succeeds without throwing, but changes the authorization’s yParity from 0x1c to 0x01, producing:
0x5547e9755be8809632ca622efb267ac59e2b3edb9f706e442aa71d0757e119e8

I independently fetched the raw transaction using eth_getRawTransactionByHash. Changing only the serialized authorization parity back to 0x1c exactly reproduces those raw bytes and the original hash.

Expected Behavior

Serialization should preserve the original authorization tuple and reproduce the transaction hash:
0xaec8420968abd74e70ef5b3099d6ba7baa3f069c4f718d7c4d729d591cffcb09

Steps To Reproduce

import {
  createPublicClient,
  http,
  keccak256,
  serializeTransaction,
} from 'viem'
import { mainnet } from 'viem/chains'

const client = createPublicClient({
  chain: mainnet,
  transport: http('https://ethereum-rpc.publicnode.com'),
})

const hash =
  '0xaec8420968abd74e70ef5b3099d6ba7baa3f069c4f718d7c4d729d591cffcb09'

const transaction = await client.getTransaction({ hash })
const serialized = serializeTransaction(transaction)

console.log(transaction.authorizationList?.[0]?.yParity)
// 28

console.log(keccak256(serialized))
// 0x5547e9755be8809632ca622efb267ac59e2b3edb9f706e442aa71d0757e119e8

console.log(keccak256(serialized) === hash)
// false

Link to Minimal Reproducible Example

No response

Anything else?

serializeAuthorizationList delegates signature encoding to toYParitySignatureArray, which coerces every nonzero numeric yParity to 1:

if (typeof yParity === 'number')
  return yParity ? numberToHex(1) : '0x'

Relevant locations:

  • src/utils/authorization/serializeAuthorizationList.ts:29
  • src/utils/transaction/serializeTransaction.ts:464

EIP-7702 permits authorization y_parity values below 2**8 at the transaction-encoding level. Authorization processing can fail and skip a tuple without invalidating the entire transaction. Such values therefore need to survive serialization unchanged, rather than being normalized to a valid signature parity.

Activity

  1. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    This issue has been locked since it has been closed for more than 14 days.

    If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.

  2. locked as resolved and limited conversation to collaborators on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions