Tokens/convert
Convert token amounts
$0.01per call after 25 free a dayConverts between normal amounts and raw units with the token's real on-chain decimals.
Run before putting any token amount in a transaction. "5 USDC" is 5,000,000 raw units; wrong decimals send 1,000x too much or too little.
Saves money. 5 USDC is 5,000,000 raw units because USDC has 6 decimals. Get the decimals wrong and you send 1,000 times too much or too little.
Call it
| Transport | How |
|---|---|
| HTTP | POST /api/tools/convert with a JSON body of the inputs below. |
| MCP | tools/call with name convert on /mcp. |
Inputs
| Name | What it's looking for | Where to get it |
|---|---|---|
tokenstring (token address) or "SOL", required | The token, or "SOL" for SOL (9 decimals). | From find_token or tokens. |
amountstring (decimal), required | The amount, as a string: "5" or "0.25". | The user's amount. A string avoids rounding errors. |
to"raw" | "readable", optional | Direction. "raw" turns 5 into 5000000 (for transactions); "readable" turns raw units back. Default "raw". | "readable" for amounts read from chain data. |
network"mainnet-beta" | "devnet", optional | Default "mainnet-beta" (real money). | "devnet" only for test wallets. |
Returned fields
Every field the tool returns, what it is, and exactly how it's worked out.
| Field | What it is | How it's worked out |
|---|---|---|
tokenstring | The token converted (SOL's own address for SOL). | Your input. "SOL" becomes So11111111111111111111111111111111111111112. |
symbolstring | null | Ticker from Jupiter, for display only. | Jupiter token search by address. |
decimalsnumber | Decimal places the token uses. | Read from the token on chain (SOL is always 9). |
decimals_fromstring | Where the decimals came from, so you can trust them. | "on-chain token" or "SOL (fixed)". |
raw_amountstring (integer) | The amount in raw units, exactly as it goes into a transfer. | amount x 10^decimals with exact integer math. Refuses more decimal places than the token has. |
amountstring (decimal) | The normal, readable amount. | raw_amount / 10^decimals with exact integer math. |
summarystring | One sentence stating the conversion. | Built from the values above. |