Method Signature
Parameters
string
required
Amount in ether
Returns
Returns the amount in wei as a bigint.Examples
- TypeScript
- JavaScript
Use in Transaction
Related Methods
Format Ether
Convert wei to ether
Parse Amount
Parse token amounts
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Convert ether to wei (raw units)
align.blockchain.utils.parseEther(ether: string): bigint
import Align from "@tolbel/align";
const align = new Align({
apiKey: process.env.ALIGN_API_KEY!,
environment: "sandbox",
});
// Convert 1 ETH to wei
const wei = align.blockchain.utils.parseEther("1.0");
console.log(wei.toString()); // "1000000000000000000"
// Convert 0.5 ETH to wei
const halfWei = align.blockchain.utils.parseEther("0.5");
console.log(halfWei.toString()); // "500000000000000000"
const weiAmount = align.blockchain.utils.parseEther("0.1");
console.log(weiAmount.toString());
const amountInEther = "0.1";
const amountInWei = align.blockchain.utils.parseEther(amountInEther);
// Use for contract call
const tx = await contract.deposit({
value: amountInWei,
});