@xchainjs/xchain-ethereum is the official Ethereum client for the XChainJS ecosystem — a modular, TypeScript-first SDK for building cross-chain wallets, crypto applications, and DeFi tooling using a unified API.
This package provides:
- an Ethereum (EVM) client implementation
- address generation and validation
- balance and transaction history lookup
- transaction creation, signing, and broadcasting
- gas and fee estimation helpers
Source package: https://github.com/xchainjs/xchainjs-lib/tree/master/packages/xchain-ethereum
Official docs: https://docs.xchainjs.org/xchain-client/xchain-ethereum/
Features
- ✅ TypeScript-first Ethereum SDK
- ✅ EVM-compatible chain support
- ✅ Address derivation from mnemonic
- ✅ Address validation
- ✅ Balance and transaction history
- ✅ ETH and ERC-20 transfers
- ✅ Gas price and fee estimation
- ✅ Unified API aligned with other XChainJS clients
How It Works
- Built on top of ethers.js for Ethereum RPC interaction
- Uses shared XChainJS abstractions and types
- Designed to behave consistently with other chain clients (BTC, LTC, THORChain, etc.)
Core dependencies:
ethers@xchainjs/xchain-client@xchainjs/xchain-util
Docs:
- How it works: https://docs.xchainjs.org/xchain-client/xchain-ethereum/how-it-works.html
- How to use: https://docs.xchainjs.org/xchain-client/xchain-ethereum/how-to-use.html
Installation
Install the package
npm install @xchainjs/xchain-ethereum
Peer dependencies
npm install @xchainjs/xchain-client @xchainjs/xchain-util ethers
Basic Usage Examples
Create an Ethereum Client
import { Client } from '@xchainjs/xchain-ethereum'
import { Network } from '@xchainjs/xchain-client'
const phrase = 'your mnemonic phrase here'
const ethClient = new Client({
phrase,
network: Network.Mainnet,
})
Get Address and Validate It
const address = ethClient.getAddress()
console.log('Address:', address)
const isValid = ethClient.validateAddress(address)
console.log('Valid:', isValid)
Get Balance
const balances = await ethClient.getBalance(address)
console.log(balances)
Balances are returned in base units and can be converted using utilities from
@xchainjs/xchain-util.
Transfer ETH
import { assetAmount, assetToBase } from '@xchainjs/xchain-util'
const recipient = '0xRecipientAddressHere'
const amount = assetToBase(assetAmount(0.01))
const txHash = await ethClient.transfer({
recipient,
amount,
memo: 'ETH transfer',
})
console.log('TX hash:', txHash)
console.log('Explorer:', ethClient.getExplorerTxUrl(txHash))
Transfer ERC-20 Tokens
const tokenAddress = '0xTokenContractAddress'
const txHash = await ethClient.transfer({
recipient,
amount,
asset: {
chain: 'ETH',
symbol: `USDT-${tokenAddress}`,
ticker: 'USDT',
},
})
Get Transaction Data
const txHash = '0xTransactionHash'
const txData = await ethClient.getTransactionData(txHash)
console.log(txData)
When to Use This Package
Use @xchainjs/xchain-ethereum if you are:
- building a crypto wallet
- interacting with Ethereum or EVM chains
- handling ETH and ERC-20 transfers
- building DeFi frontends or backends
- using XChainJS for multi-chain applications
Useful Links
GitHub source:
https://github.com/xchainjs/xchainjs-lib/tree/master/packages/xchain-ethereumDocumentation:
https://docs.xchainjs.org/xchain-client/xchain-ethereum/XChainJS main repository:
https://github.com/xchainjs/xchainjs-lib
Summary
@xchainjs/xchain-ethereum provides a clean, consistent, and production-ready
Ethereum client for the XChainJS ecosystem.
It allows developers to interact with Ethereum using the same abstractions as
other blockchains, making it easier to build cross-chain applications.
Top comments (0)