1

I have created a simple smart contract using geth and I am able to run it successfully without any issues.

The code I have used is:

pragma solidity ^0.4.13;

contract Simple {
  function arithmetics(uint _a, uint _b) returns (uint o_sum, uint o_product) {
    o_sum = _a + _b;
    o_product = _a * _b;
  }

  function multiply(uint _a, uint _b) returns (uint) {
    return _a * _b;
  }
}

I am able to run it using the command: simple.multiply.call(10,20)

The logs of all these transactions should be stored somewhere in the blockchain. Where are they stored? How can I access them?

1

You're using the method call which, as opposed to a transaction, is not reflected on the blockchain. The function you're calling is not altering blockchain state, thus no change has to be made, thus nothing is stored, thus nothing is communicated to other nodes, thus you don't need to pay anything.

This method is only called in your own node, and your node is the one computing it. There is no logs for your calls since they're only processed locally.

However, it is good practice to tag your function multiply with the label constant or view so that you explicitly tell users that this function is read only.

  • Is there any way in which I can use the same 'multiply' function as a transaction and then observe the logs? – Akhil Kintali Mar 13 '18 at 4:50
  • you can tag this method pure instead of view, since it doesn't read storage state. – Cody Django Feb 24 at 2:13
  • As @Betcheg explained, logs are only logging transactions on the blockchain. You'd have to modify the multiply function to be something that changes the contract state and then use "send" on it instead of "call". That will result in an entry showing up in the logs. – Cody Django Feb 24 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.