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

첫 USDT0 전송

Stable에서 USDT0는 체인의 기본 자산이자 ERC-20 토큰입니다. 이는 approve, transferFrom, permit이 표준 가치 전송과 함께 완벽하게 사용 가능하며, 두 경로 모두 동일한 기본 잔액에서 자금을 이동한다는 것을 의미합니다.

이 페이지에서는 두 경로를 통해 USDT0를 전송하고 단일 잔액에서 인출되는 것을 확인하는 방법을 안내합니다.

무엇을 만들 것인가요?

0.001 USDT0를 네이티브 전송으로 보내고, 0.001 USDT0를 ERC-20 전송으로 보내고, 두 잔액을 모두 출력하는 두 스크립트 플로우입니다.

데모

1단계. 지갑 연결 → 잔액 표시
        0.01 USDT0

2단계. 0.001 USDT0 전송 (네이티브 또는 ERC-20 전송 선택)

3단계. 결과
        전송됨:              0.001 USDT0
        가스 요금:           0.000021 USDT0
        네이티브 잔액:    0.008979 USDT0
        ERC-20 잔액:    0.008979 USDT0

전제 조건

  • Node.js 20 이상
  • testnet USDT0가 있는 프라이빗 키. 지갑에 자금을 지원하려면 빠른 시작을 참조하십시오.
USDT0 컨트랙트 주소
  • 메인넷: 0x779ded0c9e1022225f8e0630b35a9b54be713736
  • 테스트넷: 0x78cf24370174180738c5b8e352b6d14c83a6c9a9

설정

// config.ts
import { ethers } from "ethers";
import "dotenv/config";
 
export const STABLE_TESTNET_RPC = "https://rpc.testnet.stable.xyz";
export const CHAIN_ID = 2201;
export const USDT0_ADDRESS = "0x78Cf24370174180738C5B8E352B6D14c83a6c9A9";
 
export const provider = new ethers.JsonRpcProvider(STABLE_TESTNET_RPC);
export const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);

옵션 1 (권장): 네이티브 전송으로 전송

네이티브 전송은 이더리움에서 ETH를 보내는 것과 동일하게 작동합니다. value 필드는 USDT0 금액을 전달합니다. 네이티브 전송은 21,000 가스만 소모하며, USDT0를 보내는 가장 저렴한 방법입니다.

// sendNative.ts
import { ethers } from "ethers";
import { provider, wallet } from "./config";
 
const recipient = "0xRecipientAddress";
const amount = ethers.parseUnits("0.001", 18); // 네이티브의 경우 18 소수 자릿수
 
const block = await provider.getBlock("latest");
const baseFee = block!.baseFeePerGas!;
 
const tx = await wallet.sendTransaction({
  to: recipient,
  value: amount,
  maxFeePerGas: baseFee * 2n,
  maxPriorityFeePerGas: 0n, // Stable에서는 항상 0
});
 
const receipt = await tx.wait(1);
console.log("네이티브 전송 tx:", receipt!.hash);
npx tsx sendNative.ts
네이티브 전송 tx: 0x8f3a...2d41

옵션 2: ERC-20 전송으로 전송

USDT0는 ERC-20 전송으로도 보낼 수 있습니다. 이는 동일한 잔액에서 차감되지만, 6자리 소수점 정밀도를 가진 ERC-20 인터페이스를 사용합니다.

// sendERC20.ts
import { ethers } from "ethers";
import { wallet, USDT0_ADDRESS } from "./config";
 
const recipient = "0xRecipientAddress";
const amount = ethers.parseUnits("0.001", 6); // ERC-20의 경우 6 소수 자릿수
 
const usdt0 = new ethers.Contract(USDT0_ADDRESS, [
  "function transfer(address to, uint256 amount) returns (bool)"
], wallet);
 
const tx = await usdt0.transfer(recipient, amount);
const receipt = await tx.wait(1);
console.log("ERC-20 전송 tx:", receipt!.hash);
npx tsx sendERC20.ts
ERC-20 전송 tx: 0xa2b1...77c0

통합 잔액 확인

어떤 전송 후에도 두 잔액을 쿼리하여 동일한 소스에서 가져왔는지 확인합니다.

// balances.ts
import { ethers } from "ethers";
import { provider, wallet, USDT0_ADDRESS } from "./config";
 
const nativeBalance = await provider.getBalance(wallet.address);
console.log("네이티브 잔액:", ethers.formatEther(nativeBalance), "USDT0");
 
const usdt0 = new ethers.Contract(USDT0_ADDRESS, [
  "function balanceOf(address) view returns (uint256)"
], provider);
const erc20Balance = await usdt0.balanceOf(wallet.address);
console.log("ERC-20 잔액:", ethers.formatUnits(erc20Balance, 6), "USDT0");
npx tsx balances.ts
네이티브 잔액: 0.008979 USDT0
ERC-20 잔액: 0.008979 USDT0

두 값 모두 동일한 잔액을 나타냅니다. 소수점 잔액 조정으로 인해 최대 0.000001 USDT0까지 다를 수 있습니다.

다음 권장 사항