In this video I demonstrate how to monitor a Bitcoin address using NodeJS
Here is a quick script (full code below) that was knocked up using chatGPT to play an mp3 alert file if any Bitcoin moves from the SilkRoad address.
I set this up because the DOJ has announced they are going to sell it before Trump gets in.
Here’s a quick explainer on mempools
And here’s the code:
const axios = require('axios');
const player = require('play-sound')({player: "powershell"});
const BITCOIN_ADDRESS = 'bc1qa5wkgaew2dkv56kfvj49j0av5nml45x9ek9hz6';
const MEMPOOL_URL = `https://mempool.space/api/address/${BITCOIN_ADDRESS}/txs/mempool`;
const POLL_INTERVAL_MS = 60_000; // 60 seconds = 60000 ms
/**
* Fetch the mempool data from mempool.space API for the specified address.
* If transactions are present, play an MP3 alert sound.
*/
async function checkMempool() {
try {
const response = await axios.get(MEMPOOL_URL);
const transactions = response.data;
if (Array.isArray(transactions) && transactions.length > 0) {
console.log(`Found ${transactions.length} transactions in the mempool!`);
player.play('./alert.mp3', (err) => {
if (err) console.error('Error playing sound:', err);
});
} else {
console.log('No transactions in the mempool (blank array).');
}
} catch (error) {
console.error('Error fetching from mempool:', error);
}
}
checkMempool();
setInterval(checkMempool, POLL_INTERVAL_MS);
Code is open-sourced on Github at: https://github.com/jamesbachini/Bitcoin-Address-Watch