Skip to content

**[blocker]** The supplied payload.primaryType does not affect this signature or the digest: both calls receive only domain, the complete types map, and message; primaryType is merely echoed on line 35. With a payload that explicitly selects a declared type other than TronWeb’s inferred root, the command can therefore sign one type while reporting another. Please derive the type set rooted at the selected primaryType (or reject an incompatible selection) and use that same selection for signing, digesting, and reporting. #716

Open

Description

@Mohammedsapry

[blocker] The supplied payload.primaryType does not affect this signature or the digest: both calls receive only domain, the complete types map, and message; primaryType is merely echoed on line 35. With a payload that explicitly selects a declared type other than TronWeb’s inferred root, the command can therefore sign one type while reporting another. Please derive the type set rooted at the selected primaryType (or reject an incompatible selection) and use that same selection for signing, digesting, and reporting.

Originally posted by @matrix-agent116 in tronprotocol/wallet-cli#957 (comment)

Activity

  1. Stan202310 commented on Sep 14, 2026

    @Stan202310
    Contributor

    TronWeb derives the primaryType from types. Therefore, the types can only have one root and the corresponding sub types. You need to pass the correct types value.

  2. ramincsy commented on Sep 23, 2026

    @ramincsy

    This primaryType mismatch is a real correctness hazard for typed-data signing — especially when callers intentionally select a non-inferred root type.

    I can work on a focused fix that (1) builds the type set rooted at the supplied primaryType or rejects an incompatible selection, and (2) uses that same selection for digest, sign, and reported primaryType, with a failing fixture that currently signs the wrong root.

    If there's already preferred API behavior in mind from the wallet-cli discussion, point me at it and I'll follow that.

  3. Stan202310 commented on Oct 9, 2026

    @Stan202310
    Contributor

    Thanks for the suggestion, this makes sense.

    Today signTypedData(domain, types, value, privateKey) derives the primary type from types: the object has to contain exactly one root type plus the struct types that root references, otherwise it fails with ambiguous primary types or unused types. That is inconvenient when the payload comes from somewhere else (an EIP-712 JSON that carries EIP712Domain or extra shared types), so an explicit primaryType is a reasonable addition.

    We are currently investigating the best way to implement it. The private key is already the 4th positional argument on both the instance and the static method, so we want to settle on an API shape (an optional trailing parameter vs. an options object) that stays backward compatible and is shared by signTypedData, hashTypedData and verifyTypedData before shipping anything. We'll keep this issue open and update it once the design is decided.

    In the meantime you can get the same result by passing only the primary type and the struct types it references:

    // drop EIP712Domain and any type the primary type does not use
    const { EIP712Domain, ...types } = payload.types;
    const signature = tronWeb.trx.signTypedData(payload.domain, types, payload.message);
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