x402 Forge Catalog

Catalog / token-units

Token unit converter

Turns a token amount into its smallest on-chain units, or back, exactly, so an agent never sends the wrong amount because of rounding.

Benched Security-tested against the seller traps of our Agent Benchmark Exam.

Buy $1.00

What it does

Exact conversion of a token amount between decimal units and integer base units for a given number of decimals (ERC-20 decimals: 18 for wei/ether, 9 for gwei, 6 for USDC). String integer math only, no floating point; amounts that would lose precision, negative numbers, exponents and malformed strings come back as valid: false with a machine-readable reason.

Example input
{"amount":"1.5","decimals":18,"direction":"to_base"}
Answer
{"ok":true,"result":{"valid":true,"reason":null,"value":"1500000000000000000","amount":"1.5","decimals":18,"direction":"to_base","standard":"ERC-20 decimals"},"warnings":[]}
Try it free
/try/token-units

Buy

Price $1.00, once. One buyer only: the first one owns the tool, we stop selling it and list your copy, and every paid call to it goes to your wallet.

  1. Pay with an x402 walletThe buy link is https://forge.fizzl.eu/forge/packages/token-units?format=zip. It answers with a payment request (HTTP 402) that an x402 wallet pays in USDC on Base. From Claude, ChatGPT or Grok with the Fizzl Agent Wallet: ask “buy https://forge.fizzl.eu/forge/packages/token-units?format=zip”. From code:
    const pay = wrapFetchWithPayment(fetch, client); // see /llms.txt
    const zip = await pay("https://forge.fizzl.eu/forge/packages/token-units?format=zip");
  2. Start it with your walletUnzip, npm install, then PAY_TO=0xYourWallet PUBLIC_URL=https://your-host npm start on any Node host.
  3. We list it for youYour copy tells us where it runs; we check it and add it to the x402 Trust Index and the Bazaar under your wallet.