TL;DR
ERC-20 balances and transfers use integer units. A token's optional decimals value tells a wallet how to render those units for people. Preserve the exact integer and token identity, apply a verified scale for input and display, and keep compact rounding out of transaction confirmation. When the scale is unavailable, identify the amount as raw units or leave the familiar token amount unresolved until the wallet has evidence for it.
A wallet designer opens four views of one account. The portfolio row rounds a balance to two places. The send form holds a specific decimal entry. The confirmation sheet is about to sign an integer. An export will be imported to a workbook months later. Every view is entitled to its own layout. All four should be traceable to the same token and amount convention.
This gallery uses invented amounts and anonymous sample tokens. Its purpose is to test presentation and storage, with no real balance, wallet address, or transfer involved. The signed quantity a real application passes to an ERC-20 contract is an integer. The scale and labels a person sees originate in the application and its evidence. The challenge is to make the very different shapes of those records intelligible to a person before they approve an action.
Display specimen one — The same integer in two asset rows
Consider a sample balance with the base-unit integer 1234500. If the asset has six decimals, its ordinary token amount is 1.2345. If an entirely different asset has eighteen decimals, its sample amount is 0.0000000000012345. Both examples carry exactly the same underlying integer. The familiar amount changes because the denominator changes by a factor of a trillion. Looking at the integer alone gives no reliable clue which scale belongs to the asset.
The ERC-20 specification defines balances and transfer values using unsigned integers and describes decimals as optional metadata for usability. The OpenZeppelin guide documents eighteen as the default in its implementation and explains how that implementation can be overridden. A library default explains the output of a contract built with that default. The wallet still needs the actual applicable metadata for the contract it is displaying. ERC-20 specification and OpenZeppelin ERC-20 documentation
A precise read record includes the chain context, contract identity, base-unit amount, observed state reference as applicable, and the origin and version of the decimals information. If a portfolio row also shows a symbol and a name, they are helpful display data. They are unsafe as join keys for converting quantities because many assets can use the same symbol. The display scale associated with one contract belongs to the same identity as the amount read from that contract.
This explains why an aggregated across-networks view should preserve its component amounts. An asset on one network with a representation on another can have different contract metadata and economic properties. A portfolio application can choose to group records under an established asset mapping. It should convert each amount using its own verified scale before presenting a labeled aggregate, and only aggregate when the meaning of that sum has been defined for the user. The raw amount fields remain independently recoverable.
A zero-decimal asset illustrates the edge. The raw amount 1234500 is displayed as 1,234,500 under an English grouping convention. An entry of 1.5 would have no exact representation in base units under that scale. The form can identify this at entry and show that only whole units are supported in that field. A missing decimals response, by contrast, leaves the scale unknown. Zero is a specific scale and should survive every storage and validation layer as a valid value.
Display specimen two — The text field is a quantity parser
A test account in the gallery has a six-decimal asset. Its user enters 1.250001. The whole portion represents 1,000,000 base units. The six fractional digits represent 250,001 base units. The complete integer is 1,250,001. A reviewer can multiply or explain the sum without relying on floating-point intermediate values. The amount field can use exact integer or decimal-string handling through the final authorization step.
Now the user types 1.2500017. Seven fractional digits exceed the six available places. The wallet should visibly signal that the chosen quantity cannot be represented exactly as entered. A policy might offer the closest supported amount for the user to choose. If it does, the proposed integer and human-readable amount should reflect that new decision. Silently rounding while leaving the original string on screen would produce a commitment different from the user's visible choice.
Some formats arise from ordinary typing and pasting. A French reader can meet a comma for the decimal separator and a narrow space for grouping. A US-focused interface may expect a point. A string such as 1,234 can therefore be read as one thousand two hundred thirty-four or one and 234 thousandths under different conventions. The interface can resolve it using a declared locale or ask the user to choose when the form has accepted multiple notations. After normalization place the amount as it will be interpreted on the confirmation screen.
A different set of records contain scientific notation. A spreadsheet can turn a large integer into an exponent-form string. A form could explicitly accept such notation under strict exact rules. An ordinary wallet field can instead reject it and ask for a plain decimal so the interpretation is easy to check. Part of the test is documenting the supported grammar. Signs, whitespace, grouping, exponent syntax, and extra digits can all change how a human reads a transfer input. Acceptance should be intentional.
Preserve quantities large enough to expose conversions through binary floating point. As a fictional case, choose the integer 9007199254740993. Its exact six-decimal amount is 9007199254.740993. In JavaScript the raw integer is above the largest consecutively safe integer representable as a Number. A code path that parses it into that type can change its least significant unit before formatting. Passing the raw amount as an exact string or compatible arbitrary-precision integer avoids losing the value before the wallet has even decided how many places to show.
Test the contract's supported range separately from representation in language runtimes. Standard balance and transfer quantities occupy unsigned integer fields. A wallet should validate a user-entered amount against the applicable field and operation constraints after exact conversion. The available balance may be a much smaller bound. A signed request's quantity should match the exact reviewed amount on the chosen network and contract. Each bound belongs to a specific stage of the payment experience.
Account for digits the user enters that add no base units
Entering extra zeros past six fractional places can pose a different user-experience question from entering additional nonzero digits. The string 1.2500010 expresses the same decimal quantity as 1.250001. A wallet can specify whether its grammar accepts the longer exact representation and normalizes the trailing zeros. If it accepts it, the final confirmation can show the normalized exact quantity. The grammar still needs to reject or ask about an extra digit that changes the amount. These cases should appear together in a parser test.
The zero amount also deserves a deliberate handling decision. The standard requires ordinary treatment of zero-value transfers, including the transfer event, but a wallet's user experience can guide someone who accidentally entered zero. A user-facing validation or confirmation can reflect the product's purpose. It should describe zero accurately as a supported scale or quantity in the situations where the wallet allows it, distinct from an absent value and distinct from a rounded nonzero balance. ERC-20 transfer specification
Consider leaving a started entry as one-and-a-point while someone is typing. A text control can keep an intermediate state that won't yet become a transaction. It does not need to overwrite the user's input on every keystroke. Once they request an actionable preview, the grammar has to choose a definite amount or provide a useful correction. Separating editable text from the accepted integer allows a precise form to feel natural instead of forcing someone to retype digits after every validation step.
Display specimen three — A preview can round while the signing sheet stays exact
The home screen has little horizontal space. A six-decimal quantity of 1.234567 might be presented there as 1.23 under a chosen rounding convention. Show whether that display is abbreviated where it matters and offer a way to inspect the exact amount. The financial consequence of rounding is strongly view-dependent. A compact overview helps someone scan their portfolio. A send confirmation should allow the exact quantity to be seen without needing to infer hidden digits.
For a small holding, a rounded two-decimal display could show 0.00 even when the raw amount is positive. The application can display a bounded small-amount indicator or let the user expand to full precision. Do not let a compact row decide whether a balance exists. A transaction handler can use the integer and verified metadata even when the UI has chosen a helpful summary. Choosing to omit a low-significance display value is a distinct product rule from having no asset at all.
The opposite problem arises with enormous amounts. A layout may use abbreviated suffixes for million or billion and group some digits to make a table manageable. On a detail label, there should be a clear exact amount and identity. Copy controls can specify whether they copy the exact human-readable value or base units. If a user copies an abbreviated row, the other end might get 1.2M without a rule for restoring the removed figures. The intended copied representation deserves its own test.
A useful detail view shows the exact token quantity and, where relevant for a technical reader, the raw units. An approximation in another currency uses a rate and observation time. Many assets can trade at very different values or have no reliable quote. The token's decimals only determine the scaling of its units. They provide no exchange value. A screen that shows the token amount and a separately sourced value can label both clearly enough that users recognize which quantity would be transferred.
An order form can also use a fee display connected to a different asset. The confirmation review includes the transfer quantity and applicable fees under their own amount and unit conventions. This prevents the viewer from mistaking a fee shown in the network's asset for a deduction in the amount of the transferred token. The complete text should identify the chosen recipient and asset. Each displayed decimal is a view of the specified operation, only as far as the wallet can accurately describe it.
Preview two levels of precision from the same source
A designer asks for one amount with three fractional places in the activity feed and two on the homepage. An inherited formatter gives both screens a preformatted intermediate value. A sample with six-decimal raw units of 1234960 is exactly 1.234960 tokens. With ordinary rounding to the nearest at three decimal places, it gives 1.235. Rounding that intermediate result to two places with ties upward gives 1.24. Direct rounding from the original quantity to two places gives 1.23. The different displayed values come from two different calculations performed on one original amount.
The screen contract can choose a documented rounding rule and compute each requested view directly from the exact source. Written fixture results give reviewers a place to assess that choice. If the feed needs a three-place label and the homepage needs two, both should retain the same exact amount behind their output. This avoids using a more precise-looking view as an intermediate arithmetic input unless the product explicitly intends that result.
The issue matters even with positive amounts because small gaps can appear in reconciliation. Suppose two same-asset entries are 0.0049 tokens each under a scale capable of expressing them. Individually rounded to two places they both show 0.00 under nearest rounding. Their exact sum is 0.0098, which rounds to 0.01. A user can see a total without visible component contribution. The interface can expose the underlying amounts or add a precision indicator. Summing the rounded amounts would make a different accounting claim and erase real value.
Another acceptance case tests the number as a target the user edits. Someone starts from an exact balance that the screen displayed compactly, selects a custom amount, and sees that the input field initially holds a rounded value. The UI must make clear what editable value it inserted and recalculate the final integer from that value. A deliberate choice to insert the full exact quantity is also possible and deserves a visible exact preview. The whole experience stays intelligible when a filled text field and a raw full-balance action are treated as different interactions.
The resulting test report shows raw input, quantity after any accepted parsing, and the rounding applied at presentation. Its findings are independent of a particular rendering library. When the wallet changes design components or international formatting settings, it can repeat the same difficult values at each supported entry and copy boundary. This review focuses on preventing a silent change to the number a person commits to.
Display specimen four — The raw balance survives incomplete metadata
A wallet's token lookup occasionally gets an unavailable response. The asset contract might omit decimals under the standard's optional metadata rule. A temporary data service can fail. A token registry may not cover that asset. Preserve the balance read and the state of the relevant metadata. The interface can offer a technical display of base units to someone who understands it, with the token identity clear. A usual human-readable amount is appropriate after the scale can be established from an authorized source.
The evidence record distinguishes current contract metadata from corroborating token registry data, and acknowledges conflicting readings. If a registry lists six decimals and a retrieved result for the same network and contract indicates a different value, the wallet has a question to resolve. Verify the network, contract, method result, and any registry update assumptions before building a review amount. A transient mismatch deserves a bounded error state. Fabricating a conversion because most previously seen assets had a particular scale puts the user in an avoidable dispute with the actual amount.
Historical exports create another kind of mismatch. A team might copy an amount from an archived snapshot into a new wallet release that uses updated records from its asset registry. Preserve how the original number was represented and which unit basis it used. Where historical contract state matters, keep the snapshot identifier and metadata evidence suitable to that period. The current viewer can display this historical amount with the applicable scale, and it can show a new observation without rewriting the historical ledger.
Metadata resolution can be asynchronous. A user navigates from a six-decimal token to an eighteen-decimal token while an earlier query returns late. The UI should apply a result only to the asset it belongs to and the active request when deciding what to display. A loading or unresolved label is useful during that transition. A test that quickly changes selections can verify that no stale scale receives authority over the newer send preview. This is an ordinary state-management check on a wallet, independent of how the token contract implements its local data.
Display specimen five — The export has a reader the wallet cannot see
A downstream spreadsheet reads a comma-separated file and guesses that an unquoted amount column is numeric. It might render a large integer with few significant digits or remove trailing zeros from a decimal. The wallet can export columns for asset identity, exact base units as text in a documented representation, decimals status, human display if available, and the context of observation. A parser should use the declared representation rather than treating a formatted user-visible value as the source of truth.
Quoting a CSV field can preserve delimiters and text syntax according to how the reader parses it. Some spreadsheet applications then infer their own cell types. For a verified archival path, provide a representation the consumer can preserve, such as exact textual values with appropriate import instructions or a machine-readable format carrying strings. Test the actual import used by the reader. An output that preserves a fifteen-digit test case may still lose information at the lengths a token field can hold.
The gallery includes a round-trip record. Start with raw 1234500 and six verified decimals. Export the raw value and scale, read them back, and check that the new display is 1.2345 with the same exact integer behind it. Then perform another round trip with the large unsafe-as-Number case, and one where decimals is unknown. In the last case the successful import preserves the unresolved state. Treating the whole export as zero on a missing scale would erase the original balance.
A reader who only wants the total can still use the precise data. An aggregate can add exact integers for observations of the same asset once their comparable states and ownership scope are established. Across assets, the buyer might ask for a labeled value aggregate in a separate unit using independently chosen valuation. A single sum of all raw integers has no clear interpretation when they use distinct scales or represent separate assets. The export should give downstream readers enough labels to choose the appropriate operation.
Trace the amount across the last two screens
One useful acceptance record starts with a signed-off test packet. It names the displayed exact decimal amount, raw integer, token, chain, and intended recipient. The preview verifies that the form conversion produces the same amount as the final action. If a user changes the asset, input, or recipient before authorizing, the application recalculates and shows the new state. An old draft can stay available for review without becoming the governing record of a new request.
The test designer deliberately creates a compact value that appears identical for two underlying balances. With an abbreviated display, 1.234500 and 1.234599 can both look like 1.23. On enlargement the details reveal their difference. An interface that takes the rounded row text as input for a full-balance action would understate both. The correct source for a full-balance action is the eligible current raw amount under the business rule, with the exact amount presented for review.
Amounts also belong to a specific operation. An approval amount and a send amount can both appear in wallet records, with distinct effects and labels under the applicable contracts. Even when both quantities use the same scale, a reader should be able to tell what the page is asking them to authorize. Pay attention to which field the preview describes and which action the signing sheet carries. The format contract for a token amount cannot decide that question automatically.
Finally, a good fixture records which display decision the reviewer made. The abbreviated portfolio row displays a reasonable scan value. The summary sheet can use the same rule while directing readers to more digits. The transfer review and export preserve the exact value appropriate to their purpose. If designers change the visual layout later, the test can still exercise the same integer, token, and scale at the edges that matter. That is the practical protection against six decimals quietly disappearing between screens.