Skip to content

Instantly share code, notes, and snippets.

@iatomic1
Last active December 5, 2024 14:21
Show Gist options
  • Save iatomic1/716b3464ab30c9cfbeee063b4a79991a to your computer and use it in GitHub Desktop.
Save iatomic1/716b3464ab30c9cfbeee063b4a79991a to your computer and use it in GitHub Desktop.
Get stx balance
const { bot, forwardOrBroadCast } = require('../lib/');
bot(
{
pattern: 'balance ?(.*)',
desc: 'Gets STX balance of the address the command is replied to',
type: 'all',
},
async (message, match) => {
try {
if (!match)
return await message.send('Please provide a valid STX address!');
const res = await fetch(`https://api.hiro.so/extended/v1/address/${match}/stx`);
const json = await res.json();
await message.send(`${json.balance/1000000}STX`);
} catch (error) {
return await message.send(error.message, { quoted: message.data });
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment