# `@xchainjs/xchain-ethereum`
발행: (2025년 12월 20일 오전 01:42 GMT+9)
3 min read
원문: Dev.to
Source: Dev.to
Package Highlights
- Ethereum (EVM) 클라이언트 구현
- 주소 생성 및 검증
- 잔액 및 거래‑내역 조회
- 거래 생성, 서명 및 전송
- 가스 및 수수료 추정 도구
Features
- ✅ TypeScript‑first Ethereum SDK
- ✅ EVM‑compatible 체인 지원
- ✅ 니모닉으로부터 주소 파생
- ✅ 주소 검증
- ✅ 잔액 및 거래 내역
- ✅ ETH 및 ERC‑20 전송
- ✅ 가스 가격 및 수수료 추정
- ✅ 다른 XChainJS 클라이언트와 일치하는 통합 API
How It Works
- ethers.js 위에 구축되어 Ethereum RPC와 상호작용
- 공유 XChainJS 추상화와 타입 사용
- 다른 체인 클라이언트(BTC, LTC, THORChain 등)와 일관된 동작을 목표로 설계
Core dependencies
ethers@xchainjs/xchain-client@xchainjs/xchain-util
Documentation
- How it works:
- How to use:
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:
- 암호화폐 지갑을 구축하고 있을 때
- Ethereum 또는 기타 EVM‑compatible 체인과 상호작용할 때
- ETH 및 ERC‑20 전송을 처리할 때
- DeFi 프론트‑엔드 또는 백‑엔드를 만들 때
- 멀티‑체인 애플리케이션을 위해 XChainJS를 사용할 때
Summary
@xchainjs/xchain-ethereum은 XChainJS 생태계에 깨끗하고 일관되며 프로덕션‑레디인 Ethereum 클라이언트를 제공합니다. 다른 블록체인과 동일한 추상화를 사용해 Ethereum과 상호작용함으로써 크로스‑체인 애플리케이션 개발을 단순화합니다.