provider.getBalance
CoreAggregate spendable and receivable channel capacity by asset.
Signature
function getBalance(assetId?: string): Promise<Balance[]>PERMISSION
Requires enable(). No additional confirmation prompt in the reference providers.
Parameters
NameTypeDescription
assetIdstringReserved filter for a native CKB or UDT asset identifier. Current reference providers return all assets.
Response
NameTypeDescription
assetIdrequiredstringCKB or a provider-defined UDT type-script identifier.
spendablerequiredHexTotal local balance available for outbound payments.
receivablerequiredHexTotal remote balance available for inbound payments.
Example
const balances = await fiber.getBalance();
for (const balance of balances) {
console.log(balance.assetId, balance.spendable);
}Provider behavior
W
WASM node
Calls fiber-js listChannels() and groups local_balance / remote_balance by funding UDT type script.
R
Remote fnn
Calls fnn list_channels and aggregates the returned channel balances. Its current UDT grouping is less granular than WASM-node.
Notes
- Amounts are hexadecimal strings to avoid JavaScript integer precision loss.
- An empty array means the node has no channel balance to report.