Skip to content

[Docs] Code example bugs in Notes & Transactions quickstart (notes.md) #161

@giwaov

Description

@giwaov

Summary

The Notes & Transactions quickstart page (docs/builder/quick-start/notes.md) has three code example correctness issues that will confuse developers following the guide.

Bug 1: Expected output contradicts TypeScript code in consume section

Location: Consume Notes section — TypeScript example + expected output

The TypeScript code wraps the balance in Number():

console.log(
    "Alice's TEST token balance:",
    Number(alice.vault().getBalance(faucet.id()))
);

But the expected output shows a Result-like wrapper:

Alice's TEST token balance: Ok(1000)

These are contradictory:

  • If getBalance() returns something like Ok(1000), then Number(Ok(1000)) would produce NaN, not Ok(1000)
  • If getBalance() returns a number, the output should be 1000, not Ok(1000)

Additionally, the send section on the same page shows the same code pattern producing Alice's TEST token balance: 100 — no Ok() wrapper. So the same code path shows two different output formats within the same document.

Suggested fix: Determine the actual return type of getBalance() and correct the expected output to match what the TypeScript code actually produces. Align both the consume and send sections to use the same format.

Bug 2: Expected output uses wrong log message for send transaction

Location: Send Tokens section — TypeScript example + expected output

The TypeScript send code logs:

console.log("Send transaction submitted successfully, ID:", sendTxId.toHex());

But the expected output shows:

Send 100 tokens to Bob note transaction ID: "0x51ac27474ade3a54..."

The log message in the code says "Send transaction submitted successfully, ID:" but the expected output says "Send 100 tokens to Bob note transaction ID:". The expected output appears to be copied from the Rust example's println! rather than the TypeScript console.log.

Suggested fix: Update the expected output to match the actual TypeScript log message, or update the TypeScript code to match the expected output.

Bug 3: Unused ConsumableNoteRecord import in send.ts example

Location: Send Tokens section — TypeScript example

import {
    WebClient,
    AccountStorageMode,
    NoteType,
    ConsumableNoteRecord,  // <-- imported but never used
    AccountId,
    AuthScheme,
} from "@miden-sdk/miden-sdk";

ConsumableNoteRecord is imported but never used in the send example. This suggests the code was copy-pasted from the consume example without cleanup, which undermines confidence in the example's correctness.

Suggested fix: Remove the unused ConsumableNoteRecord import from the send.ts example.

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