Skip to main content

TypeScript: .nota Files

NotaFileClient produces, signs, parses, validates, and serializes .nota files. Everything on this page happens off-chain: no gas, no RPC calls, just local cryptography and JSON handling. The client is reached via ntm.nota.

The builder pattern

.nota files are constructed through a fluent builder. Each method returns a new or mutated NotaBuilder so you can chain:

create(options)

Starts a new builder from an options object:
CreateNotaOptions:

sign(signer)

Signs the current builder payload with an ethers Signer. Produces a 65-byte ECDSA signature over the canonical JSON digest and populates the signature section.
The builder is immutable after signing in the sense that further modifications invalidate the signature. Always sign last.

validate()

Runs structural validation against the .nota schema. Throws if any required field is missing, if chain/type values are inconsistent, or if the signature is present and does not match the payload.
Validation is cheap and intended to run on every received file before trust is placed in its contents.

parse(content)

Turns a serialized .nota JSON string back into a typed NotaFile object:
It also verifies the signature (if present) against the embedded public key or derived signer address. A failing signature raises an error.

serialize() / serialize(nota)

Canonical JSON serialization. The output is deterministic: same logical content always produces byte-identical output, so hashes line up across SDKs and platforms.
Use serialize before computing any on-chain proofHash or storing the file in IPFS.

End-to-end example