Last active
December 5, 2024 14:21
-
-
Save iatomic1/716b3464ab30c9cfbeee063b4a79991a to your computer and use it in GitHub Desktop.
Get stx balance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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