Documentation Index
Fetch the complete documentation index at: https://align.tolbel.com/llms.txt
Use this file to discover all available pages before exploring further.
Method Signature
align.blockchain.utils.parseEther(ether: string): bigint
Parameters
Returns
Returns the amount in wei as a bigint.
Examples
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());
Use in Transaction
const amountInEther = "0.1";
const amountInWei = align.blockchain.utils.parseEther(amountInEther);
// Use for contract call
const tx = await contract.deposit({
value: amountInWei,
});
Format Ether
Convert wei to ether
Parse Amount
Parse token amounts