What is the best approach to wait till the tx is mined? web3.eth.getTransactionReceipt returns null, it does not wait for completion
Oct 5, 2020, 3:28 PM
Async await?
Oct 5, 2020, 4:38 PM
I get an error if I try to use async/await: TypeError: t is not a function
Oct 5, 2020, 4:59 PM
Maybe its because t is not a function🙃. You sure you are sending transaction inside a function?
Oct 5, 2020, 5:02 PM
will get accounts is printed. then undefined and then this error
the project is written in plain JS + Jquery if that helps
I used async await in react projects and that worked fine
in this project I can't do a single async/await somehow
Oct 5, 2020, 5:04 PM
I'm not sure if async-await is used that way in Vanilla Js
try removing that const
On the top line
Oct 5, 2020, 5:12 PM
same thing
Oct 5, 2020, 5:15 PM
First of all.
1) Stop using JQuery. Now.
2) There's a high chance that the problem derives from the fact that you aren't checking if web3 and web3.eth is initialized, exist and has a function named getAccounts().
Otherwise you're calling getAccounts() while it's not there yet.
1) Stop using JQuery. Now.
2) There's a high chance that the problem derives from the fact that you aren't checking if web3 and web3.eth is initialized, exist and has a function named getAccounts().
Otherwise you're calling getAccounts() while it's not there yet.
add an if statement inside the try and check if web3.eth is there.
Oct 5, 2020, 5:16 PM
1) it is an existing project that the client asked me to build upon. I don't want to refactor everything now.
2) it works with traditional doSomething(). then(...)
2) it works with traditional doSomething(). then(...)
web3 must be there, it is enabled once the page loads
and my function is invoked upon the click of the btn
Oct 5, 2020, 5:17 PM
Ooh wait
You are working with metamask right?
Oct 5, 2020, 5:20 PM
yes sir
Oct 5, 2020, 5:20 PM
Have you written the code for enabling metamask?
Oct 5, 2020, 5:21 PM
not me but it was written
and metamask popup shows up
Oct 5, 2020, 5:21 PM
Then we will need more info on it to be able to help you. Since you get the accounts printed, then undefined then an error seems like you're calling continuously the function
Something else is wrong in your logic
Oct 5, 2020, 5:22 PM
I think he was talking about the console log before that
"Will get accounts"
Oct 5, 2020, 5:23 PM
I mean it works with simple promises but I don't like this nested hell so I want to use async/await
yes
Oct 5, 2020, 5:23 PM
ok listen, try to log(web3.eth)
instead of accounts
Oct 5, 2020, 5:24 PM
it prints an object, sir
very big object
Oct 5, 2020, 5:29 PM
don't call me sir buddy — does it prints that only once?do you get undefined and error? or not?
Oct 5, 2020, 5:29 PM
I also get this error, not sure if related but previously I didn't get it:
An invalid form control with name='' is not focusable.
An invalid form control with name='' is not focusable.
ah I guess it's because I forgot to event.preventDefault();
now no error do I see
is it safe to convert function param bytes to string in such a way:
bytes calldata _data
string(_data)
?
bytes calldata _data
string(_data)
?
how to compare big numbers with web3js?
a.lt(b) to compare that a < b is okay I suppose?
Oct 5, 2020, 7:32 PM
have to: window.ethereum.enable()
Oct 6, 2020, 3:17 AM