Skip to main content

From WEI

Converts cryptocurrency amounts from WEI or GWEI (hexadecimal format) to human-readable decimal format (ETH).

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.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Amount (GWEI) - The amount in hexadecimal format to convert (e.g., "0x0de0b6b3a7640000").

Options

  • Unit - The source unit for conversion:
    • WEI - Smallest unit (10^-18 ETH)
    • GWEI - Gas price unit (10^-9 ETH)
  • Precision - Number of decimal places in the output (default: 4).

Output

  • Amount - The converted amount in decimal format (e.g., "1.2345").

How It Works

The From WEI node converts blockchain amounts to readable format. When executed, the node:

  1. Validates the hex format (must start with "0x")
  2. Converts hex to a big integer
  3. Divides by the appropriate factor (10^18 for WEI, 10^9 for GWEI)
  4. Formats to the specified precision
  5. Returns as a decimal string

Requirements

  • Amount in hexadecimal format starting with "0x"
  • Valid hex digits after the prefix

Error Handling

The node will return errors for:

  • Amount not in hex format
  • Amount not starting with "0x"
  • Invalid hex characters
  • Conversion errors

Precision Guidelines

  • 1-2 decimals - For large amounts or when precision isn't critical
  • 4 decimals - Default, good for most display purposes
  • 6 decimals - High precision for financial applications
  • 18 decimals - Maximum precision, shows full WEI value

Usage Notes

  • Use this node to display amounts to users in friendly format
  • The Balance node already returns amounts in ETH format
  • Useful for converting raw transaction values from blockchain queries
  • Higher precision shows more decimal places
  • Minimum precision is 1 (always show at least one decimal)

Example

Converting 1 ETH from WEI:

Inputs:

  • Amount (GWEI): 0x0de0b6b3a7640000

Options:

  • Unit: wei
  • Precision: 4

Output:

  • Amount: 1.0000

Converting gas price from GWEI:

Inputs:

  • Amount (GWEI): 0x012a05f200

Options:

  • Unit: gwei
  • Precision: 2

Output:

  • Amount: 5.00

High precision conversion:

Inputs:

  • Amount (GWEI): 0x016345785d8a0000

Options:

  • Unit: wei
  • Precision: 18

Output:

  • Amount: 0.100000000000000000

Common Use Cases

Display Balances: Convert balance query results to user-friendly format.

Transaction Values: Show transaction amounts in readable form.

Gas Cost Display: Convert gas costs from WEI to ETH for reporting.

Price Calculations: Convert token prices to decimal for comparisons.

Audit Reports: Format blockchain data for human review.

User Notifications: Show payment amounts in emails or alerts.

Conversion Reference

From WEI to ETH:

  • 1,000,000,000,000,000,000 WEI = 1.0 ETH
  • 100,000,000,000,000,000 WEI = 0.1 ETH
  • 10,000,000,000,000,000 WEI = 0.01 ETH

From GWEI to ETH:

  • 1,000,000,000 GWEI = 1.0 ETH
  • 100,000,000 GWEI = 0.1 ETH
  • 10,000,000 GWEI = 0.01 ETH

Precision Examples

Same value with different precision settings:

Value: 0x016345785d8a0000 (0.1 ETH)

Precision 2:

  • Output: 0.10

Precision 4:

  • Output: 0.1000

Precision 6:

  • Output: 0.100000

Precision 18:

  • Output: 0.100000000000000000

Integration Example

Displaying transaction costs:

  1. Get Transaction - Retrieve transaction details
  2. Extract - Get gas used and gas price
  3. Calculate - Multiply: gas × gasPrice
  4. From WEI - Convert to ETH
  5. Display - Show formatted cost

Showing token balances:

  1. Call - Query token balanceOf
  2. Decode - Parse the response
  3. From WEI - Convert based on token decimals
  4. Format - Display to user
tip

Match precision to your use case. Use 2-4 decimals for display, 6+ for calculations, and 18 for exact values.

info

The From WEI node handles the division and formatting automatically. You don't need to calculate conversion factors manually.

Working with Token Decimals

Most tokens use 18 decimals like ETH:

  • USDC: 6 decimals
  • DAI: 18 decimals
  • WETH: 18 decimals

For 6-decimal tokens: Convert from the token's base unit, not WEI:

  1. Get raw balance
  2. Divide by 10^6 manually, or
  3. Adjust hex value before From WEI

For 18-decimal tokens: Use From WEI with unit=wei directly.

warning

When converting token amounts, always check the token's decimal places. Using wrong decimals will display incorrect values.

Display Formatting

For UI Display:

  • Use 2-4 decimals
  • Trim trailing zeros if desired
  • Add thousands separators externally

For Calculations:

  • Use 6+ decimals
  • Keep full precision
  • Round only at final display

For Audit Trails:

  • Use maximum precision (18)
  • Store original hex values
  • Show both hex and decimal