To WEI
Converts cryptocurrency amounts from decimal format (ETH) to WEI or GWEI in hexadecimal format for use in blockchain transactions.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Amount - The amount to convert as a string or number (e.g., "1.5" or 1.5).
Options
- Unit - The target unit for conversion:
- WEI - Smallest unit (10^-18 ETH)
- GWEI - Gas price unit (10^-9 ETH)
Output
- Amount (GWEI) - The converted amount in hexadecimal format (e.g., "0x0de0b6b3a7640000").
How It Works
The To WEI node converts human-readable amounts to blockchain-compatible format. When executed, the node:
- Parses the input amount (string or number)
- Converts to a big float for precision
- Multiplies by the appropriate factor (10^18 for WEI, 10^9 for GWEI)
- Converts to a big integer
- Formats as hexadecimal with "0x" prefix
- Returns the hex-encoded value
Requirements
- A valid numeric amount (string or number)
- Amount must be parseable as a decimal number
Error Handling
The node will return errors for:
- Invalid amount format
- Non-numeric amount values
- Amount parsing failures
- Conversion errors
Conversion Reference
WEI Conversions:
- 1 ETH = 1,000,000,000,000,000,000 WEI (10^18)
- 0.1 ETH = 100,000,000,000,000,000 WEI
- 0.01 ETH = 10,000,000,000,000,000 WEI
- 0.001 ETH = 1,000,000,000,000,000 WEI
GWEI Conversions:
- 1 ETH = 1,000,000,000 GWEI (10^9)
- 0.1 ETH = 100,000,000 GWEI
- 0.01 ETH = 10,000,000 GWEI
- 0.001 ETH = 1,000,000 GWEI
Usage Notes
- Always use this node before sending amounts in transactions
- The output is in hexadecimal format required by blockchain operations
- WEI is used for transaction values
- GWEI is commonly used for gas prices
- The conversion maintains full precision
- Works with any decimal input up to 18 decimal places
Example
Converting 1.5 ETH to WEI:
Inputs:
- Amount:
1.5
Options:
- Unit:
wei
Output:
- Amount (GWEI):
0x0000000000000000000000000000000000000000000014d1120d7b160000
Converting gas price to GWEI:
Inputs:
- Amount:
50
Options:
- Unit:
gwei
Output:
- Amount (GWEI):
0x000000000000000000000000000000000000000000000000000ba43b7400
Converting small amounts:
Inputs:
- Amount:
0.001
Options:
- Unit:
wei
Output:
- Amount (GWEI):
0x00000000000000000000000000000000000000000000000038d7ea4c68000
Common Use Cases
Transaction Values: Convert ETH amounts to WEI before transferring.
Gas Price Calculation: Convert gas price from GWEI to the required hex format.
Token Amounts: Convert decimal token amounts accounting for decimals.
Payment Processing: Convert user-friendly amounts to blockchain format.
Budget Limits: Set spending limits in decimal, convert to WEI for enforcement.
Dynamic Pricing: Convert calculated prices to transaction-ready format.
String vs Number Input
Both formats work:
String:
"1.5"
Number:
1.5
Use strings for maximum precision with many decimal places.
When working with user input or external data, always convert amounts using To WEI before creating transactions. This ensures proper formatting and prevents errors.
The hex output may look long and complex, but it's the standard format required by Ethereum and compatible blockchains.
Integration Example
Complete flow for sending ETH:
- Input - Get amount from user:
1.5 - To WEI - Convert to WEI format
- Transfer - Create transfer with hex amount
- Send Transaction - Execute the transfer
Complete flow for token transfer:
- Input - Get amount:
100 - To WEI - Convert considering token decimals
- ABI Method - Encode transfer with converted amount
- Send Transaction - Execute token transfer
Precision Handling
The node handles very small and very large numbers:
Very small:
- 0.000000000000000001 ETH = 1 WEI
Very large:
- 1,000,000 ETH converts accurately
Decimal precision:
- Up to 18 decimal places supported
- No rounding errors for valid amounts
Always verify converted amounts are correct before sending transactions. While the conversion is precise, input errors (extra zeros, wrong decimals) will be faithfully converted and could result in sending wrong amounts.