Console.log - Solidity contract

How to log text and value, in Solidity contract,
during development

let value = instance.balance;
console.log("value: {}", value);

does not work.

Hey @SpiritOfThe9

it("Should return the contract value:", async function(){
     let balance = await web3.eth.getBalance(People.address);
     console.log('the contract balance is: ' + balance);

Schermata 2020-09-02 alle 12.23.20



Thx. I understand.

However, instance.balance is declared as:
uint public balance;

but during runtime it’s a function,

  it("should earn when person added", async function(){
    let instance = await People.deployed();
    let before = instance.balance;
    console.log('before: ' + before);


before: function() {
      var defaultBlock = "latest";
     return promiEvent.eventEmitter;

I guess it’s a JS thing !?
I thought I could access balance with dot-notation, since I have the instance.

Can you please explain what I’m missing here !?

If you have a public variable in your contract, you can do the following to access it from your test.js file.

  it("Should return the contract value:", async function(){ (res) {
1 Like