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 토큰입니다. 가스 토큰은 별도의 네이티브 자산이 아닌 USDT0입니다. 표준 이더리움 가스 추정은 세 가지를 조정하면 그대로 작동합니다: maxPriorityFeePerGas는 항상 0이고, baseFee는 USDT0로 표기되며, 네이티브 전송에서 value 필드는 ETH가 아닌 USDT0를 담습니다.

이 가이드는 Stable에서 트랜잭션을 올바르게 구성하는 방법과 이더리움 코드를 이식할 때 무엇을 변경해야 하는지 보여줍니다.

이더리움과의 차이점

필드이더리움Stable
가스 토큰ETHUSDT0
maxPriorityFeePerGas순서 지정에 사용됨무시됨 (0으로 설정)
baseFeePerGasETH로 표기USDT0로 표기
value (네이티브 전송)ETH 전송USDT0 전송
EIP-1559 트랜잭션 형식지원됨지원됨
eth_estimateGas, eth_gasPrice지원됨지원됨
eth_maxPriorityFeePerGas팁 반환0 반환

트랜잭션 형식이 변경되지 않으므로 기존 ethers.js, viem, Hardhat, Foundry 코드는 변경 없이 Stable에서 실행됩니다. 차이는 가스 필드를 인코딩하는 방식이 아니라 계산하는 방식에 있습니다.

트랜잭션 구성하기

base fee를 가져오고, maxPriorityFeePerGas0으로 설정하고, 안전 마진으로 base fee를 두 배로 합니다.

// sendNative.ts
import { ethers } from "ethers";
import "dotenv/config";
 
const provider = new ethers.JsonRpcProvider("https://rpc.testnet.stable.xyz");
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
 
const block = await provider.getBlock("latest");
const baseFee = block!.baseFeePerGas!;
 
const maxPriorityFeePerGas = 0n; // always 0 on Stable
const maxFeePerGas = baseFee * 2n + maxPriorityFeePerGas; // 2x headroom
 
const tx = await wallet.sendTransaction({
  to: "0xRecipientAddress",
  value: ethers.parseEther("0.001"), // 0.001 USDT0, 18 decimals
  maxFeePerGas,
  maxPriorityFeePerGas,
});
 
const receipt = await tx.wait(1);
console.log("Tx:", receipt!.hash);
console.log("Gas used:", receipt!.gasUsed.toString());
console.log("Effective gas price:", receipt!.gasPrice.toString(), "(USDT0 wei-equivalent)");
npx tsx sendNative.ts
Tx: 0x8f3a...2d41
Gas used: 21000
Effective gas price: 1000000000 (USDT0 wei-equivalent)

실효 가스 가격은 USDT0로 표기된 값입니다. 1 gwei에서 21,000 가스 네이티브 전송은 약 0.000021 USDT0의 비용이 듭니다.

USDT0로 가스 비용 추정하기

eth_estimateGaseth_gasPrice는 이더리움과 동일하게 동작합니다. 가스 토큰이 USDT0이므로 결과는 이미 USDT0 단위입니다.

// estimate.ts
import { ethers } from "ethers";
 
const provider = new ethers.JsonRpcProvider("https://rpc.testnet.stable.xyz");
 
const gasPrice = await provider.send("eth_gasPrice", []);
const gasEstimate = await provider.estimateGas({
  to: "0xContractAddress",
  data: "0x...",
});
 
const feeInUSDT0 = BigInt(gasPrice) * gasEstimate;
console.log("Estimated fee:", ethers.formatEther(feeInUSDT0), "USDT0");
npx tsx estimate.ts
Estimated fee: 0.000021 USDT0

툴링 구성

  • Hardhat / Foundry: 특별한 구성이 필요 없습니다. 표준 EVM 설정이 작동합니다. 구성에서 priority fee를 명시적으로 설정한다면 0으로 설정하세요.
  • 지갑: priority 팁 입력 필드를 숨기거나 비활성화하세요. 이 값은 순서 지정이나 포함에 영향을 미치지 않으므로 표시하는 것은 오해를 일으킵니다.
  • 모니터링: 수수료 분석 대시보드는 priority fee를 차트로 표시하지 않아야 합니다. Stable에서는 항상 0입니다.

이더리움에서 이식할 때 흔한 실수

  • ETH로 표기된 팁 적용: 이더리움에서 priority-fee 상수를 복사한다고 해서 더 빠른 포함이 이루어지지 않습니다. Stable은 base fee만으로 트랜잭션 순서를 정합니다.
  • value를 ETH로 취급: 네이티브 전송의 value는 USDT0입니다. ETH/USD 가격으로 변환하지 마세요.
  • 수수료 상한 하드코딩: 고정 값 대신 실시간 baseFeePerGas로부터 maxFeePerGas를 설정하세요(예: baseFee * 2). 그래야 base fee가 상승할 때 트랜잭션이 멈추지 않습니다.

다음 추천