Skip to main content

suix_getTotalSupply

Returns the total circulating supply of a specified coin type on the Sui network.

Overview​

The suix_getTotalSupply method provides essential information about the total circulating supply of any coin type on Sui. This method is crucial for tokenomics analysis, market cap calculations, DeFi protocols, analytics platforms, and any application that needs to understand the monetary supply of tokens within the Sui ecosystem.

Parameters​

ParameterTypeRequiredDescription
coinTypestringYesThe coin type identifier in format: packageId::module::type

Coin Type Format​

The coin type follows the standard Sui format: packageId::module::type

Common examples:

  • SUI: 0x2::sui::SUI
  • USDC: 0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC
  • Custom tokens: 0xpackageId::module::COIN_NAME

Returns​

Returns the total supply information for the specified coin type.

FieldTypeDescription
valuestringTotal supply in the smallest unit (raw amount)

Supply Calculation​

  • The returned value represents the total circulating supply
  • Values are returned in the smallest unit (e.g., MIST for SUI)
  • Use suix_getCoinMetadata to get decimal places for proper formatting
  • Supply reflects all minted coins minus any burned coins

Code Examples​

# Get SUI total supply
curl -X POST https://sui-mainnet.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "suix_getTotalSupply",
"params": [
"0x2::sui::SUI"
],
"id": 1
}'

# Get USDC total supply
curl -X POST https://sui-mainnet.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "suix_getTotalSupply",
"params": [
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"
],
"id": 1
}'

# Get custom token total supply
curl -X POST https://sui-mainnet.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "suix_getTotalSupply",
"params": [
"0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT"
],
"id": 1
}'

Response Example​

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"value": "10000000000000000000"
}
}

Formatted Example (with metadata)​

For SUI with 9 decimals, the raw value 10000000000000000000 represents:

  • Formatted: 10,000,000,000 SUI
  • Display: 10,000,000,000.0000 SUI

Common Use Cases​

1. Market Cap Calculations​

async function calculateMarketCap(coinType, priceUSD) {
const [supply, metadata] = await Promise.all([
getTotalSupply(coinType),
client.getCoinMetadata({ coinType })
]);

const formattedSupply = Number(supply.value) / Math.pow(10, metadata.decimals);
const marketCap = formattedSupply * priceUSD;

return {
coinType: coinType,
symbol: metadata.symbol,
supply: formattedSupply,
price: priceUSD,
marketCap: marketCap,
formattedMarketCap: `$${marketCap.toLocaleString()}`
};
}

2. Tokenomics Analysis​

async function analyzeTokenomics(coinType) {
const supply = await getFormattedTotalSupply(coinType);

if (!supply) return null;

// Analyze supply characteristics
const analysis = {
symbol: supply.symbol,
totalSupply: supply.formattedSupply,
supplyCategory: categorizeSupply(supply.formattedSupply),
inflationRisk: assessInflationRisk(supply.formattedSupply),
liquidityIndicator: calculateLiquidityIndicator(supply.formattedSupply),
scarcityScore: calculateScarcityScore(supply.formattedSupply)
};

return analysis;
}

function categorizeSupply(supply) {
if (supply >= 1_000_000_000_000) return 'Ultra High Supply';
if (supply >= 100_000_000_000) return 'Very High Supply';
if (supply >= 1_000_000_000) return 'High Supply';
if (supply >= 100_000_000) return 'Medium-High Supply';
if (supply >= 1_000_000) return 'Medium Supply';
if (supply >= 100_000) return 'Low-Medium Supply';
if (supply >= 10_000) return 'Low Supply';
return 'Very Low Supply';
}

3. DeFi Protocol Monitoring​

async function monitorProtocolSupplies(protocolTokens, callback) {
const tracker = new SupplyTracker(client);

setInterval(async () => {
const changes = await tracker.trackMultipleSupplies(protocolTokens);

const significantChanges = Object.entries(changes).filter(
([, change]) => Math.abs(Number(change.absoluteChange)) > 0
);

if (significantChanges.length > 0) {
callback({
timestamp: new Date().toISOString(),
changes: significantChanges.map(([coinType, change]) => ({
coinType,
change: change.absoluteChange,
percentage: change.percentageChange
}))
});
}
}, 30000); // Check every 30 seconds
}

4. Portfolio Value Calculator​

async function calculatePortfolioValue(holdings, prices) {
const totalValue = {
totalUSD: 0,
breakdown: []
};

for (const holding of holdings) {
const supply = await getFormattedTotalSupply(holding.coinType);
const price = prices[holding.coinType] || 0;

if (supply && price > 0) {
const holdingPercentage = Number(holding.balance) /
Math.pow(10, supply.decimals) / supply.formattedSupply * 100;

const holdingValue = (Number(holding.balance) /
Math.pow(10, supply.decimals)) * price;

totalValue.breakdown.push({
symbol: supply.symbol,
holdings: Number(holding.balance) / Math.pow(10, supply.decimals),
percentage: holdingPercentage,
value: holdingValue,
totalSupply: supply.formattedSupply
});

totalValue.totalUSD += holdingValue;
}
}

return totalValue;
}

Best Practices​

1. Supply Data Caching​

// Cache supply data with reasonable TTL since it changes infrequently
const supplyCache = new Map();
const SUPPLY_CACHE_TTL = 5 * 60 * 1000; // 5 minutes

async function getCachedTotalSupply(coinType) {
const cached = supplyCache.get(coinType);

if (cached && Date.now() - cached.timestamp < SUPPLY_CACHE_TTL) {
return cached.data;
}

const supply = await getTotalSupply(coinType);

if (supply) {
supplyCache.set(coinType, {
data: supply,
timestamp: Date.now()
});
}

return supply;
}

2. Precision Handling​

// Use BigInt for precise supply calculations
function calculateSupplyRatio(supply1, supply2) {
const s1 = BigInt(supply1);
const s2 = BigInt(supply2);

if (s2 === BigInt(0)) return null;

// Calculate ratio with high precision
const ratio = (s1 * BigInt(10000)) / s2; // 4 decimal places
return Number(ratio) / 10000;
}

3. Error Handling​

async function safeGetTotalSupply(coinType) {
try {
const supply = await getTotalSupply(coinType);

if (!supply || !supply.value) {
return {
success: false,
error: 'No supply data available'
};
}

return {
success: true,
data: supply
};
} catch (error) {
return {
success: false,
error: error.message,
retry: !error.message.includes('not found')
};
}
}

Supply Interpretation​

Understanding Supply Values​

  1. Raw Values: Always returned in smallest unit (e.g., MIST for SUI)
  2. Total vs Circulating: This method returns total circulating supply
  3. Burned Tokens: Burned tokens are automatically subtracted from supply
  4. Minting Events: New minting increases the total supply immediately

Supply Categories​

  • Deflationary: Supply decreases over time through burning
  • Inflationary: Supply increases through ongoing minting
  • Fixed: Supply is capped and cannot increase
  • Elastic: Supply adjusts based on market conditions

Notes​

  • Supply can change due to minting, burning, or staking operations
  • Values are real-time and reflect the current blockchain state
  • Use metadata to properly format supply values for display
  • Large numbers may require BigInt handling in JavaScript
  • Monitor changes for tokens with dynamic supply models

Need help? Contact our support team or check the Sui documentation.