How do I make a call to the setName() function of this simple contract from web3? I am able to make a call to the getName() function from web3 and receive the correct value in console. I just don't know how to call setter methods from web3. Kindly help. Thanks! :)

Mar 3, 2019, 12:27 PM
These ^ are some of the things I've tried so far. Nothing seems to work :(
Mar 3, 2019, 12:28 PM
Try with then instead of callbacks function
Mar 3, 2019, 1:10 PM
Tried. Doesn't work..
Mar 3, 2019, 1:12 PM
Do one thing
Before calling setName , log userAddress
Mar 3, 2019, 1:13 PM
I have hardcoded userAddress above the code in the screenshot. It shouldn't be any issue. Console logging userAddress works just fine.
Mar 3, 2019, 1:45 PM
Show me error
Mar 3, 2019, 1:49 PM
Try this:
1. Add Contract ABI to ja File
2. Add contract address to file
3. call function directly from the contract

As for example shown here:
https://stackoverflow.com/questions/48184969/calling-smart-contracts-methods-using-web3-ethereum
Mar 3, 2019, 2:01 PM
Yes, I've tried this as well. Doing this didn't result in any error, but it made the program stuck forever. I first thought that the transaction is taking time, but nothing happened for a long time so I just had to Ctrl+C. Not sure what the problem was..
Mar 3, 2019, 2:09 PM
Problem is that this Call uses gas
You somehow need to confirm the transaction
If you call this function in a browser with metamask, fo example, metamask will pop up and wants you to confirm
„Problem“ == difference (between the two functions)
Mar 3, 2019, 2:10 PM
exactly show us error so that we can help u accordingly
i think for testing string is okay, it looks like he is learning so
for real life usage bytes should be preferred, it's cost efficient
i also prefer async and await over then
Mar 3, 2019, 3:15 PM
This is the error I was getting on running this code:
Mar 3, 2019, 5:55 PM

© 2024 Draquery.com All rights reserved.