eth_getBalance RPC 方法
▾ How to check TIP-20 token balances
Since Tempo does not have a native token, you need to query TIP-20 stablecoin contracts directly to check account balances. Use the balanceOf function on the token contract.
Example using ethers.js:
const ethers = require('ethers');
const NODE_URL = "YOUR_QUICKNODE_ENDPOINT";
const provider = new ethers.JsonRpcProvider(NODE_URL);
// pathUSD token contract address
const PATHUSD_ADDRESS = "0x20c0000000000000000000000000000000000000";
async function checkTokenBalance(address) {
const abi = ["function balanceOf(address) view returns (uint256)"];
const tokenContract = new ethers.Contract(PATHUSD_ADDRESS, abi, provider);
const balance = await tokenContract.balanceOf(address);
// TIP-20 tokens use 6 decimal places
const formattedBalance = ethers.formatUnits(balance, 6);
console.log(`pathUSD balance: ${formattedBalance}`);
}
checkTokenBalance("0x9729187D9E8Bbefa8295F39f5634cA454dd9d294");
Available TIP-20 stablecoins:
| Token | Address |
|---|---|
| pathUSD | 0x20c0000000000000000000000000000000000000 |
| AlphaUSD | 0x20c0000000000000000000000000000000000001 |
| BetaUSD | 0x20c0000000000000000000000000000000000002 |
| ThetaUSD | 0x20c0000000000000000000000000000000000003 |
參數
地址
字串
必填
載入中...
區塊編號
字串
必填
載入中...
退貨
結果
字串
載入中...
請求
回應
1{2"jsonrpc": "2.0",3"id": 1,4"result": "0x9612084f0316e0ebd5182f398e5195a51b5ca47667d4c9b26c9b26c9b26c9b2"5}
1{2"jsonrpc": "2.0",3"id": 1,4"result": "0x9612084f0316e0ebd5182f398e5195a51b5ca47667d4c9b26c9b26c9b26c9b2"5}