-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method "tx.wait()" loses context #355
Comments
Absolutely this is a bug. I will get to it right away. Thanks! :) |
Great, thanks! Just a small related question - is there any way to get the result of the modifying function call? For example, the code of the contract is like that: function addPatientContract(address userAddress) public returns (address) {
// some state modification
return someContractAddress;
} Is any way to retrieve that |
This isn't possible in Ethereum as a whole, unfortunately. If you need the value, you will have to log an event. Only a If every return value were stored in the state trie it would quickly increase the size of the blockchain unnecessarily, since the vast majority of transactions do not require the return value in the receipt. To store it explicitly, you use a log (called "events" in Solidity), so that the caller pays for it and it is explicitly marked as necessary, and is included in the receipt, optionally indexing it (à la bloom filters) with the That said, there are usually other ways to solve this problem, such as getters, when eventually consistent is enough (or recoverable, in the case of orphans). Make sense? |
Definitely it does - seems like I missed that part. Thanks a lot! |
This has been fixed in Thanks! :) |
Just checked it out - works perfectly on version |
https://cdn.ethers.io/scripts/ethers-v4.min.js still has the 4.0.11 version which has this bug. I generally use webpack, but currently on a project that needed the cdn version. Thanks @sweetpalma for creating the issue, got the temporary solution for now. And thanks @ricmoo for solving! |
Oh! I’ll update the CDN version shortly. In v5, it is part of the publish operation, so it won’t become out of sync anymore. |
Recently discovered strange bug on a version
4.0.13
. I tried running modifying methods of my contract like that:But encountered the following error:
I've investigated a bit and found that it may be cause by losing
this
context on this line: https://github.com/ethers-io/ethers.js/blob/master/src.ts/contract.ts#L283So I tried to do a direct call without using
.functions
wrapper - and it worked:It is a pretty minor bug - but it would be great to have this fixed. Thanks for your awesome library anyway - it is really great and a way more concise than web3 is.
The text was updated successfully, but these errors were encountered: