convert
Run before putting any token amount into a transaction. "5 USDC" is 5,000,000 raw units; wrong decimals send 1,000x too much or too little. Converts between normal amounts and raw units using the token's real on-chain decimals. Inputs: token: The token, or "SOL" for SOL (9 decimals). amount: The amount to convert, as a string, e.g. "5" or "0.25". to (optional): Which way to convert. "raw" turns 5 into 5000000 (for transactions). "readable" turns raw units back into a normal amount. Default "raw". network (optional): Which Solana network to read. Default "mainnet-beta" (real money). Cost: 25 free calls a day, then $0.01 USDC per call (x402). Full field-by-field docs: GET /api/tools/convert.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Which way to convert. "raw" turns 5 into 5000000 (for transactions). "readable" turns raw units back into a normal amount. Default "raw". "raw" before building a transaction, "readable" when reading raw amounts. | raw |
| token | Yes | The token, or "SOL" for SOL (9 decimals). From find_token or tokens. | |
| amount | Yes | The amount to convert, as a string, e.g. "5" or "0.25". The amount the user asked for. A string avoids rounding errors. | |
| network | No | Which Solana network to read. Default "mainnet-beta" (real money). Leave it out for mainnet. Use "devnet" only for test wallets. | mainnet-beta |