logo
Getting started

Managing Your Balance

Request faucet NFSC (test) and check your balance across chains

Request NFSC Faucet (Test)

Use client.user.requestNfscFaucet to request test NFSC. If you refer to this as requestNFSC internally, this is the client method to call.

import { createNamefiClient } from '@namefi/api-client';

const client = createNamefiClient({
  authentication: {
    apiKey: process.env.NAMEFI_API_KEY!,
    type: 'API_KEY',
  },
  logger: true,
});

const faucet = await client.user.requestNfscFaucet({});

console.log('Status', faucet.status); // started
console.log('Workflow ID', faucet.workflowId);
console.log('Wallet', faucet.walletAddress);
console.log('Next eligible at', faucet.nextEligibleAt);

To request for a specific linked wallet:

await client.user.requestNfscFaucet({
  walletAddress: '0x1111111111111111111111111111111111111111',
});

If you hit rate limits, the API returns 429 with the next eligible timestamp.

Top Up in Production

Use the Namefi dashboard to top up NFSC in production environments.

Check Your Balance

Use GET /v4/balance/details to check linked wallet balances across supported chains. Each entry has readStatus: 'ok' with confirmed amounts (including zero), or readStatus: 'unavailable' with null amounts. rawBalance is the exact amount as an integer string in 18-decimal NFSC base units. The USD and cents fields are numeric display values. Cents can include fractions.

The knownBalanceInUsd and knownBalanceInUsdCents fields always contain the subtotal of confirmed reads. When isComplete is true, the total fields equal those subtotals and all rows are confirmed. When it is false, both total fields are null. Display the confirmed subtotal as partial. An account with no linked wallets has complete zero totals. If every attempted read fails, the API returns 503 SERVICE_UNAVAILABLE. Retry the request in that case.

Use GET /v4/balance or client.balance.getBalance() when you need a complete balance. It returns HTTP 503 if any read fails.

This example requires an SDK release that includes getBalanceDetails().

import { createNamefiClient } from '@namefi/api-client';

const client = createNamefiClient({
  authentication: {
    apiKey: process.env.NAMEFI_API_KEY!,
    type: 'API_KEY',
  },
  logger: true,
});

const balance = await client.balance.getBalanceDetails();

if (balance.isComplete) {
  console.log('Total USD', balance.totalBalanceInUsd);
} else {
  console.log('Confirmed subtotal (USD)', balance.knownBalanceInUsd);
}

for (const entry of balance.balances) {
  const amount = entry.readStatus === 'ok' ? `$${entry.balanceInUsd}` : 'unavailable';
  console.log(`${entry.chainName} (${entry.chainId}) - ${entry.walletAddress}: ${amount}`);
}

On this page