Ether
The Ether class represents the native ETH currency on Ethereum mainnet and testnets.
Import
import { Ether } from '@uniswap/sdk-core-next'Creating Ether
Use the static onChain method to get an Ether instance:
import { Ether } from '@uniswap/sdk-core-next'
// Ethereum mainnet
const eth = Ether.onChain(1)
// Sepolia testnet
const sepoliaEth = Ether.onChain(11155111)
// Instances are cached - same chain returns same instance
Ether.onChain(1) === Ether.onChain(1) // trueProperties
isNative
readonly isNative: trueAlways true for Ether.
isToken
readonly isToken: falseAlways false for Ether.
chainId
readonly chainId: numberThe chain ID (1 for mainnet).
decimals
readonly decimals: 18Always 18 for ETH.
symbol
readonly symbol: 'ETH'Always 'ETH'.
name
readonly name: 'Ether'Always 'Ether'.
wrapped
get wrapped(): TokenReturns the WETH9 token for the chain.
const eth = Ether.onChain(1)
const weth = eth.wrapped
console.log(weth.address) // '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
console.log(weth.symbol) // 'WETH'Throws: If WETH9 is not defined for the chain.
Methods
equals(other)
equals(other: Currency): booleanReturns true if the other currency is also a native currency on the same chain.
const eth1 = Ether.onChain(1)
const eth2 = Ether.onChain(1)
const sepoliaEth = Ether.onChain(11155111)
eth1.equals(eth2) // true
eth1.equals(sepoliaEth) // false (different chain)Example Usage
import { Ether, CurrencyAmount, Token } from '@uniswap/sdk-core-next'
const eth = Ether.onChain(1)
const weth = eth.wrapped
// Create an ETH amount (1 ETH)
const ethAmount = CurrencyAmount.fromRawAmount(eth, '1000000000000000000')
console.log(ethAmount.toSignificant(6)) // "1"
console.log(ethAmount.currency.symbol) // "ETH"
// Convert to wrapped amount for contract interactions
const wrappedAmount = ethAmount.wrapped
console.log(wrappedAmount.currency.symbol) // "WETH"
console.log(wrappedAmount.currency.address) // WETH addressSupported Chains
Ether can be created for any chain, but the wrapped property requires a WETH9 entry in the WETH9 mapping.