0

Recently, I was reading a paper in which the writers stated that

"In the Ethereum smart contract, the return value of the nonconstant function can only be obtained through logs event."

However, I think that you can retrieve a value from a non-constant function by using myContract.func.call(). What is your opinion? Thanks!

(Btw, a similar question has been asked here; Truffle: 'func.call()' retrieves the return-value of a non-constant function but it is not answered).

John
  • 35
  • 4

1 Answers1

0

myContract.getValue.call() - constant function => read current state (does not create any transaction).

myContract.setValue.send() - non-constant function => write (create transaction) and must be mined. Because of this, you cannot obtain the result immediately. A workaround for this is to just emit the event.

MentatX
  • 144
  • 4