Catalog/evm-units

EVM

Convert token amounts (wei/decimals) API

Convert a token amount between human and raw integer forms given its decimals (e.g. 1.5 USDC <-> 1500000). Handles the big-number/decimals math agents get wrong.

Price$0.01per request
MethodPOST
Route/v1/evm/units
StatusLive
MIME typeapplication/json
Rate limit120/minute
CacheNo cache
evmunitsweidecimalsconverterc20
API URLhttps://x402.hexl.dev/v1/evm/units
Integration docs
Example request
{
  "value": "1.5",
  "decimals": 6,
  "direction": "toRaw"
}
Example response
{
  "input": "1.5",
  "decimals": 6,
  "direction": "toRaw",
  "result": "1500000"
}
Input schema
{
  "type": "object",
  "required": [
    "value",
    "direction"
  ],
  "properties": {
    "value": {
      "type": "string",
      "examples": [
        "1.5",
        "1500000000000000000"
      ]
    },
    "decimals": {
      "type": "number",
      "minimum": 0,
      "maximum": 36,
      "default": 18
    },
    "direction": {
      "type": "string",
      "enum": [
        "toRaw",
        "toHuman"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "required": [
    "input",
    "decimals",
    "direction",
    "result"
  ],
  "properties": {
    "input": {
      "type": "string"
    },
    "decimals": {
      "type": "number"
    },
    "direction": {
      "type": "string"
    },
    "result": {
      "type": "string"
    }
  }
}