Ethers.js: Return Value from Non-View/Pure External Function

Created on 13 Oct 2020  Ā·  3Comments  Ā·  Source: ethers-io/ethers.js

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?

discussion

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.methodNameHere to get the result, barring in mind this isn’t actually updating any state.

Does that make sense?

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dev1644 picture dev1644  Ā·  42Comments

ruzpuz picture ruzpuz  Ā·  26Comments

MicahZoltu picture MicahZoltu  Ā·  24Comments

fmsouza picture fmsouza  Ā·  51Comments

ricmoo picture ricmoo  Ā·  24Comments