Skip to content

Instantly share code, notes, and snippets.

@ernestognw
Last active January 11, 2020 20:38
Show Gist options
  • Save ernestognw/71208bfffaded4954b21c6621dbc5f51 to your computer and use it in GitHub Desktop.
Save ernestognw/71208bfffaded4954b21c6621dbc5f51 to your computer and use it in GitHub Desktop.
Stellar balance checker script
// 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