Skip to content

Instantly share code, notes, and snippets.

@critesjosh
Created April 9, 2020 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save critesjosh/35ba7b1c2fe41934308cb243b003001c to your computer and use it in GitHub Desktop.
Save critesjosh/35ba7b1c2fe41934308cb243b003001c to your computer and use it in GitHub Desktop.
A node.js script to print details about the Celo blockchain that is connected at http://localhost:8545
// Run this script in a npm project with contractkit installed
// https://www.npmjs.com/package/@celo/contractkit
const Kit = require('@celo/contractkit')
const CeloContract = Kit.CeloContract
const kit = Kit.newKit('http://localhost:8545')
async function wrapper(){
let accounts = await kit.web3.eth.getAccounts()
let balance = await kit.getTotalBalance(accounts[0])
const goldTokenAddress = await kit.registry.addressFor(CeloContract.GoldToken)
const stableTokenAddress = await kit.registry.addressFor(CeloContract.StableToken)
const registryAddress = await kit.registry.addressFor(CeloContract.Registry)
const validatorsAddress = await kit.registry.addressFor(CeloContract.Validators)
console.log("Accounts: ", accounts)
for (let [key, value] of Object.entries(balance)) {
console.log(`${key}: ${value.toString(10)}`);
}
console.log("Gold Token Address: ", goldTokenAddress)
console.log("Stable Token Address: ", stableTokenAddress)
console.log("Registry Address: ", registryAddress)
console.log("Validators Address: ", validatorsAddress)
}
wrapper()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment