@tevm/voltaire / index / BrandedEther
BrandedEther
Type Aliases
BrandedEther
BrandedEther = EtherType
Defined in: src/primitives/Denomination/EtherType.ts:12
EtherType
EtherType =Defined in: src/primitives/Denomination/EtherType.ts:9 Branded Ether type - represents Ethereum amounts in ether (10^18 wei) Uses string to support decimal values like “1.5” or “0.001” For whole number wei amounts, use WeiType (bigint)string&object
Type Declaration
[brand]
readonly[brand]:"Ether"
Variables
Ether
Defined in: src/primitives/Denomination/ether-index.ts:19constEther:object
Type Declaration
from()
from: (Create Ether from bigint, number, or string Ether is a string type to support decimal values like “1.5” or “0.001”value) =>EtherType
Parameters
value
Value to convert (bigint, number, or string)string | number | bigint
Returns
EtherType
Ether amount as branded string
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
If value is not a valid numberExample
fromGwei()
fromGwei: (Convert Gwei to Ether Converts gwei string to ether string (divides by 10^9). Alias for Gwei.toEther().gwei) =>EtherType
Parameters
gwei
GweiType
Amount in Gwei (string)
Returns
EtherType
Amount in Ether (string)
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
Example
fromWei()
fromWei: (Convert Wei to Ether Converts bigint wei to decimal string ether value. Alias for Wei.toEther().wei) =>EtherType
Parameters
wei
WeiType
Amount in Wei (bigint)
Returns
EtherType
Amount in Ether (string with decimal precision)
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
Example
toGwei()
toGwei: (Convert Ether to Gwei Converts ether string to gwei string (multiplies by 10^9).ether) =>GweiType
Parameters
ether
EtherType
Amount in Ether (string)
Returns
GweiType
Amount in Gwei (string)
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
Example
toU256()
toU256: (Convert Ether to Uint256 (in Wei) Converts ether string to wei bigint, then returns as Uint256.ether) =>Type
Parameters
ether
EtherType
Amount in Ether (string)
Returns
Type
Uint256 value in Wei
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
If ether value has more than 18 decimal placesExample
toWei()
toWei: (Convert Ether to Wei Parses decimal string and converts to bigint wei value.ether) =>WeiType
Parameters
ether
EtherType
Amount in Ether (string, supports decimals like “1.5”)
Returns
WeiType
Amount in Wei (bigint)
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
If ether value has more than 18 decimal placesExample
GWEI_PER_ETHER
Defined in: src/primitives/Denomination/ether-constants.ts:15 Number of Gwei in one Ether (10^9)constGWEI_PER_ETHER:1000000000n=1_000_000_000n
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0WEI_PER_ETHER
Defined in: src/primitives/Denomination/ether-constants.ts:7 Number of Wei in one Ether (10^18)constWEI_PER_ETHER:1000000000000000000n=1_000_000_000_000_000_000n
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Functions
from()
from(Defined in: src/primitives/Denomination/ether-from.ts:21 Create Ether from bigint, number, or string Ether is a string type to support decimal values like “1.5” or “0.001”value):EtherType
Parameters
value
Value to convert (bigint, number, or string)string | number | bigint
Returns
EtherType
Ether amount as branded string
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
If value is not a valid numberExample
fromGwei()
fromGwei(Defined in: src/primitives/Denomination/ether-fromGwei.ts:22 Convert Gwei to Ether Converts gwei string to ether string (divides by 10^9). Alias for Gwei.toEther().gwei):EtherType
Parameters
gwei
GweiType
Amount in Gwei (string)
Returns
EtherType
Amount in Ether (string)
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
Example
fromWei()
fromWei(Defined in: src/primitives/Denomination/ether-fromWei.ts:22 Convert Wei to Ether Converts bigint wei to decimal string ether value. Alias for Wei.toEther().wei):EtherType
Parameters
wei
WeiType
Amount in Wei (bigint)
Returns
EtherType
Amount in Ether (string with decimal precision)
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
Example
toGwei()
toGwei(Defined in: src/primitives/Denomination/ether-toGwei.ts:23 Convert Ether to Gwei Converts ether string to gwei string (multiplies by 10^9).ether):GweiType
Parameters
ether
EtherType
Amount in Ether (string)
Returns
GweiType
Amount in Gwei (string)
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
Example
toU256()
toU256(Defined in: src/primitives/Denomination/ether-toU256.ts:21 Convert Ether to Uint256 (in Wei) Converts ether string to wei bigint, then returns as Uint256.ether):Type
Parameters
ether
EtherType
Amount in Ether (string)
Returns
Type
Uint256 value in Wei
See
https://voltaire.tevm.sh/primitives/denomination for Denomination documentationSince
0.0.0Throws
If ether value has more than 18 decimal placesExample
toWei()
toWei(Defined in: src/primitives/Denomination/ether-toWei.ts:23 Convert Ether to Wei Parses decimal string and converts to bigint wei value.ether):WeiType
Parameters
ether
EtherType
Amount in Ether (string, supports decimals like “1.5”)
Returns
WeiType
Amount in Wei (bigint)

