Watching Changes
WatchWalletChanges
new WatchWalletChanges(timeout?: number)
new WatchWalletChanges(timeout?: number)Parameter
Type
Default
Description
watch(callback)
watch(callback)watch(callback: ({ address: string; network: string; networkPassphrase: string }) => void)stop()
stop()Example
import { WatchWalletChanges } from "@stellar/freighter-api";
const watcher = new WatchWalletChanges(1000); // poll every second
watcher.watch((changes) => {
console.log("Address:", changes.address);
console.log("Network:", changes.network);
console.log("Passphrase:", changes.networkPassphrase);
});
// Stop after 30 seconds
setTimeout(() => watcher.stop(), 30000);Last updated
Was this helpful?
