Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

sign_doc_canonical_json

Encode a SignDoc as canonical JSON: recursive sort_keys, no whitespace, drops None from data.

Signature

def sign_doc_canonical_json(sign_doc: SignDoc) -> bytes

Example

from dango.utils.signing import sign_doc_canonical_json
from dango.utils.types import SignDoc
 
raw = sign_doc_canonical_json(sign_doc)
print(raw.decode("utf-8"))

Parameters

sign_docSignDoc. The TypedDict with sender, gas_limit, messages, data.

Returns

bytes — UTF-8 encoded JSON with sorted keys (recursively) and no whitespace. None values in data are dropped to match the chain's canonical form (the chain's Metadata struct uses skip_serializing_none).

Notes

  • Mirrors grug::SignData::to_prehash_sign_data exactly. Hand to sign_doc_sha256 for the 32-byte digest.

See also