# `@xchainjs/xchain-litecoin`

발행: (2025년 12월 20일 오전 01:39 GMT+9)
4 min read
원문: Dev.to

Source: Dev.to

이 패키지가 제공하는 것

  • 라이트코인 Client 구현 (UTXO‑스타일 체인)
  • 주소 생성 및 검증
  • 잔액, 거래 내역, 거래‑데이터 조회
  • 수수료‑예측 도우미 (getFeeRates, getFeesWithMemo 등)

Source package:

XChainJS docs:

기능

  • ✅ TypeScript‑first 라이트코인 SDK
  • ✅ BIP44/84 주소 파생 지원 (메인넷 및 테스트넷)
  • ✅ 니모닉 구문으로 주소 생성
  • ✅ 주소 검증
  • ✅ 잔액, 거래 내역 및 해시별 거래 데이터 조회
  • ✅ LTC 전송
  • ✅ 수수료 추정 도우미 (getFeeRates, getFeesWithMemo, …)

How it works (under the hood)

  • bitcoinjs-lib을 사용하여 UTXO 트랜잭션을 빌드하고 서명합니다.
  • 기본 공개 데이터 제공 엔드포인트로 SoChain API v2를 사용합니다.
  • 탐색기 URL은 Blockstream을 참조합니다.
  • 공유 XChainJS 패키지에 의존합니다: @xchainjs/xchain-client, @xchainjs/xchain-crypto, @xchainjs/xchain-util.

References

  • 문서 “How it works”:
  • 문서 “How to use”:

설치

패키지 설치

yarn add @xchainjs/xchain-litecoin

피어 의존성

공식 문서에 따르면, 다음도 설치하세요:

yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util \
         axios bitcoinjs-lib coininfo wif

기본 사용 예시

새 Litecoin 클라이언트에 지갑 연결하기

import { Client } from '@xchainjs/xchain-litecoin'
import { Network } from '@xchainjs/xchain-client'
import { baseToAsset } from '@xchainjs/xchain-util'

const connectWallet = async () => {
  const phrase = 'your mnemonic phrase here'
  const ltcClient = new Client({ network: Network.Mainnet, phrase })

  const address = ltcClient.getAddress()
  console.log('Address:', address)

  const isValid = ltcClient.validateAddress(address)
  if (!isValid) throw new Error('Invalid address')

  const balances = await ltcClient.getBalance(address)
  const readable = baseToAsset(balances[0].amount).amount()
  console.log('Balance:', readable.toString())
}

connectWallet().catch(console.error)

Litecoin (LTC) 전송

import { Client, LTC_DECIMAL } from '@xchainjs/xchain-litecoin'
import { assetToBase, assetAmount } from '@xchainjs/xchain-util'

const transferLitecoin = async () => {
  const phrase = 'your mnemonic phrase here'
  const recipient = 'ltc recipient address here'

  const ltcClient = new Client({ phrase })

  const amount = assetToBase(assetAmount(0.01, LTC_DECIMAL))

  const txid = await ltcClient.transfer({
    amount,
    recipient,
    memo: 'memo',
  })

  console.log('TX sent:', txid)
  console.log('Explorer:', ltcClient.getExplorerTxUrl(txid))
}

transferLitecoin().catch(console.error)

전송 수수료 및 수수료‑비율 추정값 가져오기

import { Client } from '@xchainjs/xchain-litecoin'
import { baseToAsset } from '@xchainjs/xchain-util'

const returnFees = async () => {
  const phrase = 'your mnemonic phrase here'
  const ltcClient = new Client({ phrase })

  const { fast, fastest, average } = await ltcClient.getFees()
  console.log('Fast:', baseToAsset(fast).amount().toString())
  console.log('Fastest:', baseToAsset(fastest).amount().toString())
  console.log('Average:', baseToAsset(average).amount().toString())

  const feeRates = await ltcClient.getFeeRates()
  console.log('FeeRates:', feeRates)
}

returnFees().catch(console.error)

transfer 매개변수에 feeRate를 전달할 수 있습니다:

// feeRates.fastest is a number
await ltcClient.transfer({
  amount,
  recipient,
  memo: 'memo test',
  feeRate: feeRates.fastest,
})

거래 데이터 및 거래 내역 가져오기

import { Client } from '@xchainjs/xchain-litecoin'

const transactionData = async () => {
  const phrase = 'your mnemonic phrase here'
  const ltcClient = new Client({ phrase })

  const hash = 'your tx hash'
  const txData = await ltcClient.getTransactionData(hash)
  console.log('TxData:', txData)
}

transactionData().catch(console.error)

유용한 링크

  • 패키지 소스 (GitHub):
  • 문서 (개요):
  • 문서 (작동 방식):
  • 문서 (사용 방법):
in-litecoin/how-to-use.html
Back to Blog

관련 글

더 보기 »

# `@xchainjs/xchain-ethereum`

@xchainjs/xchain-ethereum는 XChainJS 생태계의 공식 Ethereum 클라이언트이며, 모듈식이고 TypeScript‑first SDK로서 크로스‑체인 지갑 및 crypto를 구축하기 위해 사용됩니다.

Vue + XChainJS 예제

Vue + XChainJS 예제의 커버 이미지 https://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads...

# XChainJS 거래 확인 예제

이 예제는 XChainJS를 사용하여 블록체인 트랜잭션을 확인하고 추적하는 방법을 보여줍니다. 라이브 데모 및 소스 코드 - 라이브 데모 CodeSandbox: - 소스 코드 GitHub: