Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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