Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

지갑 생성

Stable 지갑은 이더리움 표준 키 페어입니다. EVM 계정을 생성하는 모든 지갑 라이브러리는 수정 없이 Stable에서 작동합니다. 이 가이드는 두 가지 방법을 보여줍니다. 대부분의 애플리케이션을 위한 ethers.js와 에이전트 및 결제를 위한 턴키 자체 보관 계층을 원하는 통합을 위한 Tether의 WDK (Wallet Development Kit)입니다.

전제 조건

  • Node.js 20 이상.

옵션 1: ethers.js

라이브러리를 설치하고 키 페어를 생성합니다.

npm install ethers
// wallet.ts
import { ethers } from "ethers";
 
const provider = new ethers.JsonRpcProvider("https://rpc.testnet.stable.xyz");
 
/** 새 사용자를 위한 새 지갑을 생성합니다. */
export function createWallet() {
  const wallet = ethers.Wallet.createRandom(provider);
  return {
    wallet,
    address: wallet.address,
    seedPhrase: wallet.mnemonic!.phrase, // 백업을 위해 사용자에게 한 번 표시
  };
}
 
/** 시드 구문으로 지갑을 복원합니다 (기존 사용자). */
export function restoreWallet(seedPhrase: string) {
  const wallet = ethers.Wallet.fromPhrase(seedPhrase, provider);
  return { wallet, address: wallet.address };
}
 
if (import.meta.url === `file://${process.argv[1]}`) {
  const { address, seedPhrase } = createWallet();
  console.log("Address:    ", address);
  console.log("Seed phrase:", seedPhrase);
}
npx tsx wallet.ts
Address:     0xAlice...1234
Seed phrase: liberty shoot ... (12 words)

옵션 2: Tether WDK

WDK는 키 도출, 서명 및 트랜잭션 제출을 단일 인터페이스로 묶습니다. 일반적인 계정 흐름을 재구현하지 않고 자체 보관을 원할 때 적합하며, 에이전트 결제를 위해 x402와 직접 통합됩니다.

npm install @tetherto/wdk @tetherto/wdk-wallet-evm
// wallet-wdk.ts
import WDK from "@tetherto/wdk";
import WalletManagerEvm from "@tetherto/wdk-wallet-evm";
 
function initWdk(seedPhrase: string) {
  return new WDK(seedPhrase)
    .registerWallet("stable", WalletManagerEvm, {
      provider: "https://rpc.testnet.stable.xyz",
    });
}
 
/** 새 사용자를 위한 새 지갑을 생성합니다. */
export async function createWallet() {
  const seedPhrase = WDK.getRandomSeedPhrase();
  const wdk = initWdk(seedPhrase);
  const account = await wdk.getAccount("stable", 0);
  return {
    account,
    address: await account.getAddress(),
    seedPhrase, // 백업을 위해 사용자에게 한 번 표시
  };
}
 
/** 시드 구문으로 지갑을 복원합니다 (기존 사용자). */
export async function restoreWallet(seedPhrase: string) {
  const wdk = initWdk(seedPhrase);
  const account = await wdk.getAccount("stable", 0);
  return { account, address: await account.getAddress() };
}
npx tsx wallet-wdk.ts
Address:     0xAlice...1234
Seed phrase: liberty shoot ... (12 words)

지갑 자금 조달

지갑이 트랜잭션을 수행하기 전에 가스용 USDT0가 필요합니다. 테스트넷에서는 수도꼭지에서 요청하세요.

open https://faucet.stable.xyz

주소를 붙여넣고 버튼을 선택하여 1 테스트넷 USDT0를 받습니다 (수천 번의 기본 전송에 충분함). 메인넷의 경우, 지원되는 모든 거래소 또는 브릿지에서 USDT0를 보냅니다. Stable로 USDT0 브릿지하기를 참조하세요.

잔액 확인

네이티브 USDT0는 18개의 소수 자릿수를 사용합니다. 가스가 지불되는 것은 네이티브 잔액입니다.

// balance.ts
import { ethers } from "ethers";
 
const provider = new ethers.JsonRpcProvider("https://rpc.testnet.stable.xyz");
const balance = await provider.getBalance("0xYourAddress");
console.log("Balance:", ethers.formatEther(balance), "USDT0");
npx tsx balance.ts
Balance: 1.0 USDT0

다음 권장 사항