Skip to content

docs(how-to-guide): a beginner page for amounts, units and addresses - #421

Open
IanoNjuguna wants to merge 2 commits into
IntersectMBO:feat/tutorial-live-codeblockfrom
IanoNjuguna:feat/cardano-numbers-page
Open

IanoNjuguna wants to merge 2 commits into
IntersectMBO:feat/tutorial-live-codeblockfrom
IanoNjuguna:feat/cardano-numbers-page

Conversation

@IanoNjuguna

@IanoNjuguna IanoNjuguna commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

A new page under How To Guide → Beginner, next to "Inputs and Outputs" and "Addresses", with three runnable examples. It covers the representations every API expects and no page currently explains: an amount, a token unit, and the address prefix that names its network.

Position 3 in that folder, three jsx live blocks, plus the two sentences that link it to the Addresses page and back. Neither page pointed at the other before, which is a gap worth closing in the same change: the Addresses page explains why a payment and a stake credential are separate, this one shows how to read the prefix and header byte that carry them.

Closes #419, which asked for both this page and the theme it depends on. Stacked on #420, which brings the theme these blocks need.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • I have tested these changes locally
  • I have checked for broken links
  • Code examples have been tested

Checklist

  • My code follows the style guidelines
  • I have performed a self-review
  • I have made corresponding changes to documentation

What the page says

  1. Amounts are whole numbers. The ledger counts lovelace, one ADA is one million of them, and there are no decimals anywhere, so rounding is a wallet's business. The block converts both ways, and the prose keeps the one JavaScript trap that matters: never compare ADA arithmetic, convert first.
  2. Every token has a unit. lovelace for ADA, otherwise the 56-hex-character policy ID followed by the asset name in hex, with no separator. The block builds a unit from a policy ID and a name, validates the policy ID length, and shows that an empty name is legal.
  3. The address declares its network. bech32 prefix, then the header byte, which says whether the credentials are a key, a script or a pointer. The block reports network and kind for whatever you paste, including the Byron case.

Verification

Built and served locally, then driven through CDP with real addresses rather than eyeballed:

addr_test1qzlwg5c3…qqrr00q9   prefix addr_test   testnet    base address, key payment credential
addr1qzlwg5c3…qqrr00q9        prefix addr         mainnet    base address, key payment credential
stake1uyehkck0…gh6ffgw        prefix stake        mainnet    reward (stake) address, key credential
addr_test1wzlwg5c3…pjtq       prefix addr_test   testnet    enterprise address, script payment credential

All three blocks render and react, no reload, no horizontal overflow, and npm run build passes with onBrokenLinks: throw. The two new cross-links are checked in the built output: the Addresses page links to /docs/how-to-guide/beginner/numbers-and-identifiers/ and back to /docs/how-to-guide/beginner/address/.

One bug found and fixed during that pass: the separator lookup was lastIndexOf('1'), which a typo in the data part can defeat. Bech32's data alphabet has no 1 in it, so indexOf('1') is the correct read, and the page now uses that.

Notes

  • The address check reads the prefix and the header byte only. It does not verify the checksum, and the page says so under the block instead of leaving the reader to assume otherwise.
  • The default value is the real preview address already in this repo's docs, not an invented placeholder.
  • Slots and epochs are described in prose, not as a widget. Converting a slot needs systemStart and slotLength from the network's genesis file, and a plausible-looking constant on a testnet page would be worse than no widget.
  • The parameters section points at /epochs/latest/parameters and the genesis file rather than quoting numbers that governance can change.

The three representations every API expects, each with a block a reader can
edit: ADA to lovelace, an asset name to its unit, and an address to its
network and credential kind.

The limits are on the page rather than implied: the address check reads the
prefix and the header byte and does not verify the checksum, and protocol
parameters are pointed at their real source instead of being hardcoded.
The two are neighbours and neither pointed at the other: Addresses explains why
a payment and a stake credential are separate, Numbers and Identifiers shows
how to read the prefix and header byte that carry them.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant