Timeline for Solidity getter function returning "undefined" while trying to get value using Ethersjs
Current License: CC BY-SA 4.0
18 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 8 at 2:06 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Jun 8 at 11:03 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Jan 28 at 20:02 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Sep 28, 2023 at 11:02 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
May 23, 2023 at 23:00 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Jan 19, 2023 at 12:02 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Sep 20, 2022 at 16:04 | history | bumped | CommunityBot | This question has answers that may be good or bad; the system has marked it active so that they can be reviewed. | |
Apr 21, 2022 at 17:45 | answer | added | Rushank Savant | timeline score: 0 | |
Apr 21, 2022 at 17:42 | comment | added | Rushank Savant | I found the solution. The Profile_name is defined using let (which should not be a problem). But when I define it as a State it's getting updated and not giving any errors. Thanks a lot for your replies! | |
Apr 21, 2022 at 14:32 | comment | added | Nergon |
Since the value of Profile_name is updated in an async manner then it is possible that you are trying to access it before the value is populated, given you have properly setup scoping of your variable.
|
|
Apr 21, 2022 at 12:49 | comment | added | Majd TL | add more details how are you calling it and show more code from the script. I have no ideas but maybe someone else will find the error | |
Apr 21, 2022 at 11:03 | comment | added | Rushank Savant | Profile_name is showing the value in console, but it is showing undefined when used outside the updateName function. (Profile_name is defined outside the updateName function scope) | |
Apr 21, 2022 at 10:24 | comment | added | Majd TL | try this please: let tx = await Profile_contract.updateName(name); console.log(tx.hash); await tx.wait(); Profile_name = await Profile_contract.getter(0); console.log(Profile_name); | |
Apr 21, 2022 at 9:42 | comment | added | Majd TL | docs.ethers.io/v4/api-contract.html#connecting-to-a-contract it looks okay. no idea what is the problem | |
Apr 21, 2022 at 9:23 | history | edited | Rushank Savant | CC BY-SA 4.0 |
deleted 2 characters in body
|
Apr 21, 2022 at 9:22 | comment | added | Rushank Savant | Yea, i guess the same. Sorry i wrote const here, have used let in main script. Can you tell how usually we call a view function using ethersjs? | |
Apr 21, 2022 at 9:13 | comment | added | Majd TL | the contract works on remix. therefore the problem is in your script. why is Profile_name a const :/ ? | |
Apr 21, 2022 at 8:11 | history | asked | Rushank Savant | CC BY-SA 4.0 |