Portal Community

convertUnits

Converts between lamports (the base unit) and SOL. Pure computation — no RPC call is made, so it works even if no cluster is configured.

FieldTypeRequiredDescription
lamportstext (integer)Exactly one of lamports / solAmount in lamports to convert to SOL.
soltext (decimal)Exactly one of the twoAmount in SOL to convert to lamports.

Example response (given sol: "1.5"):

{
  "lamports": 1500000000,
  "sol": 1.5
}
1 SOL = 1,000,000,000 lamports (109). Supply exactly one of lamports or sol — the response always includes both, so a single call gives you either direction.
Why this exists as its own operation: Every field that carries a lamport amount elsewhere on this node (transaction/sendNative's lamports, the balance responses) is a raw integer, deliberately kept as text rather than a numeric control to avoid JavaScript/JSON Number.MAX_SAFE_INTEGER precision loss on large values. Use convertUnits to translate a user-friendly SOL amount collected upstream (e.g. a form field) into the lamport integer a write operation expects.