Convert a Cosmos bank denomination into its display unit
A chain may register several names and scales for one bank asset. The metadata identifies which unit a user interface should display.
Read the units for one base denomination
Run the query against a TLS gRPC endpoint with reflection in GRPC. Match the metadata display name to its entry in denomUnits and read its exponent.
grpcurl -d '{"denom":"uatom"}' "$GRPC" cosmos.bank.v1beta1.Query/DenomMetadata
For base uatom and a display unit with exponent 6, a raw balance of 12003400 formats as 12.0034 display units. Split the integer at six digits to preserve small amounts without floating-point rounding.
Handle an unregistered asset
Missing metadata leaves the raw base denomination usable. Show that denomination explicitly until another verified metadata source supplies a scale. Retain the chain ID and base denomination in storage because display symbols can coincide. github.com Cosmos SDK Query API