Last active
January 11, 2020 20:38
-
-
Save ernestognw/71208bfffaded4954b21c6621dbc5f51 to your computer and use it in GitHub Desktop.
Stellar balance checker script
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
// utils/check-balance.js | |
const StellarSdk = require("stellar-sdk"); | |
const dotenv = require("dotenv"); | |
dotenv.config(); | |
const server = new StellarSdk.Server("https://horizon-testnet.stellar.org"); | |
const checkBalance = async () => { | |
// Cargamos la cuenta a través del sdk de Stellar | |
const account = await server.loadAccount(process.env.PUBLIC_KEY); | |
console.log("Balances for account: " + process.env.PUBLIC_KEY); | |
// Checamos cada una de las cuentas y su balance | |
account.balances.forEach(balance => { | |
console.log("Type:", balance.asset_type, ", Balance:", balance.balance); | |
}); | |
}; | |
checkBalance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment