Hi, how do I constantly read contract method. So it instantly change when supply change.
const currentSupply = await contract.methods.totalSupply().call();
Hi, how do I constantly read contract method. So it instantly change when supply change.
const currentSupply = await contract.methods.totalSupply().call();
if it is your contract, or if there is an event when the total supply changes, then you could listen for events
I have whole thing for contract methods in:
if (window.ethereum){
//contract methods
const currentSupply = await contract.methods.totalSupply().call();
}
If I change “if” to “while”, it will constantly read, but will it be ok for website?
I don’t think that it would be ok, as it will do it in a loop, you can add a delay of some seconds between the call
How exactly can I do that?
there is something like a sleep that can add a delay, you have an example here: Cloud Function calling it self again after hitting error (?)
I’ve added 2 seconds of delay, do you think that will be enough.
it could help, you could try with different number of seconds if it doesn’t work well