Convert to Smallest Unit (Wei)
Convert a human-readable decimal amount (e.g. '3.75') to its smallest-unit integer representation (e.g. '3750000' for USDC with 6 decimals). Uses string math — no floating-point errors. Works for any ERC-20 token.
Built-in action Built In
Convert a human-readable decimal amount (e.g. '3.75') to its smallest-unit integer representation (e.g. '3750000' for USDC with 6 decimals). Uses string math — no floating-point errors. Works for any ERC-20 token.
At a Glance
| Field | Value |
|---|---|
| Action ID | convert-to-wei |
| Category | Built In |
| Connector | Not required |
| Requires gas | No |
| Funds movement | None declared |
| Tags | utility, transformer, wei, token, conversion, onchain |
Payload Schema
| Field | Type | Required | Description |
|---|---|---|---|
value | string | Yes | Human-readable decimal amount to convert. Supports workflow variables like {{node.result.amount}}. |
decimals | number | Yes | Number of decimals for the token. Common values: 6 (USDC, USDT), 8 (WBTC), 18 (ETH, most ERC-20). |
Result Schema
| Field | Type | Required | Description |
|---|---|---|---|
wei | string | Yes | Integer string in smallest units (wei). No decimal point. Use this value for on-chain transactions. |
Examples
json{ "type": "convert-to-wei", "payload": { "value": "3.75", "decimals": 6 }, "children": []}
bashcurl -X POST "https://api.b3os.org/v1/actions/convert-to-wei/test" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "value": "3.75", "decimals": 6 }}'
Payload fields can use workflow expressions such as {{$trigger.body.amount}}, {{$nodes.fetch.result.price}}, and {{$props.asset}} when the value should come from a trigger, prior node, or reusable workflow prop.
