Guys let's suppose I let users use chainlink to request a random number, what's the most convenient way to listen to when their request is answered and display them the number?

Jul 5, 2022, 2:41 PM
you mean in frontend? using javascript?
Jul 5, 2022, 3:50 PM
Yeah, I can emit an event on the "callback" but then I just listen to that through web3 or are there other options?
Jul 5, 2022, 3:53 PM
i normally send the transaction, put an spinning circle with a message until the transaction has been mined and has enough confirmations and then i remove the spinning circle and show the value

i normally use ethers instead of web3 so the snippet would be something like

setLoading(true) // popup spinner
let result = await contract.method()
setLoading(false) //

show the value or whatever
Jul 5, 2022, 4:00 PM
Yeah but in this case imagine the flow as: you call function A, you have to wait B to call function C
And when B calls C you display to the user the result of the call to C
On fe we can't know when the call to C will happen (but it's expected in a reasonable time), and idk if I can open a wss connection for each user that needs to wait for a result
Jul 5, 2022, 4:05 PM

© 2024 Draquery.com All rights reserved.