MCPcopy Create free account
hub / github.com/CashScript/cashscript / getBalance

Method getBalance

packages/cashscript/src/Contract.ts:77–80  ·  view source on GitHub ↗

* Retrieve the total BCH balance of the contract by summing the satoshis of all UTXOs at the * contract's address. * * @returns The total balance in satoshis.

()

Source from the content-addressed store, hash-verified

75 * @returns The total balance in satoshis.
76 */
77 async getBalance(): Promise<bigint> {
78 const utxos = await this.getUtxos();
79 return utxos.reduce((acc, utxo) => acc + utxo.satoshis, 0n);
80 }
81
82 /**
83 * Retrieve all UTXOs (confirmed and unconfirmed) locked at the contract's address.

Callers 7

Contract.test.tsFile · 0.80
mecenas.tsFile · 0.80
announcement.tsFile · 0.80
p2pkh.jsFile · 0.80
p2pkh.tsFile · 0.80
hodl_vault.tsFile · 0.80

Calls 1

getUtxosMethod · 0.95

Tested by

no test coverage detected