Is it true that the only way for ethers.js to get the return value from a non-view/pure function is to get it from an event emitted from the function?
If a function is state-changing, that is the only way for any value to be returned to the client from the blockchain.
If you wish to āsimulateā a state-changing method though, you can use the contract.callStatic.methodNameHere to get the result, barring in mind this isnāt actually updating any state.
Does that make sense?
I think the OP has been answered, so I'm going to close this now, but please feel free to re-open if not.
Thanks! :)
For clarification, here is the relevant link to the documentation:
https://docs.ethers.io/v5/api/contract/contract/#contract-callStatic
Most helpful comment
If a function is state-changing, that is the only way for any value to be returned to the client from the blockchain.
If you wish to āsimulateā a state-changing method though, you can use the
contract.callStatic.methodNameHereto get the result, barring in mind this isnāt actually updating any state.Does that make sense?