Skip to content

Subscribe Balance

balance.subscribeBalance()

Subscribe to balance updates as they occur.

ts
import { 
WalletDirector
} from '@fedimint/core'
import {
WasmWorkerTransport
} from '@fedimint/transport-web'
const
director
= new
WalletDirector
(new
WasmWorkerTransport
())
const
wallet
= await
director
.
createWallet
()
await
wallet
.
open
()
const
unsubscribe
=
wallet
.
balance
.
subscribeBalance
((
mSats
) => {
console
.
log
('Balance updated:',
mSats
)
// 1000 mSats = 1 satoshi }) // ...Cleanup Later
unsubscribe
()