sdk.towei
Home > @openformat/sdk > toWei
toWei() function
Convert a decimal Ether amount (ETH) to its smallest unit (wei) as a BigNumber.
Signature:
export declare function toWei(amount: string): BigNumber;
Parameters
| Parameter | Type | Description |
|---|---|---|
| amount | string | The decimal Ether amount to be converted to wei. |
Returns:
BigNumber
{BigNumber} The converted wei amount as a BigNumber instance.
Example
const decimalAmount = "0.01"; const weiAmount = toWei(decimalAmount); console.log(weiAmount.toString()); // "10000000000000000"