Shoutout @rolznz for always being open and helpful. I asked him how he was persisting the donations in his Sat Parity Tracker app.
He told me he was using an isolated read-only NWC connection. After taking a look at his code, I saw how simple it was to do something like this.
All that was needed was the
nwc
package from the @Alby SDK and a NWC connection string. This string is usually kept secret but it’s in the open here for demonstration purposes. Plus, it’s read-only as mentioned earlier.Using the NWCClient object and the connection secret, the transactions can be fetched (and displayed in this case).
const fetchTransactions = async () => {
try {
const client = new nwc.NWCClient({
nostrWalletConnectUrl: DONATION_CONNECTION_SECRET,
});
const txResponse = await client.listTransactions({});
const formattedTransactions = txResponse.transactions
// Do something with the transactions (e.g. display them)
} catch (error) {
console.error("Error fetching transactions:", error);
}
};
Ofc, the best way to learn is to do. So I immediately added an NWC page to the Bullish Prototype and essentially did the same thing but with a little extra formatting.