#Listening blockchain events issue

1 messages · Page 1 of 1 (latest)

toxic moth
#

Hi guys,
I'm trying to listen for events from a smart contract in my WebGL game. I added the WebSocket URL to the ChainSafe settings and added the EventServiceAdapter to the Web3Unity prefab. I can see the log 'Start polling event' and also see events on the explorer, but Unity isn't receiving any. So, I don't know what's wrong.
Here is my chain settings:

west gorge
#

Hey @toxic moth if you're polling events you don't need a web socket link, we just use the RPC SDK to check for changes every interval make sure your Event Service Adapter is on your Web3Unity instance and could you maybe switch your rpc to something from Infuria (now Metamask) https://developer.metamask.io/

toxic moth
#

Just replace the rpc url with metamask one?

#

Do I need to re-deploy the smart contract?

west gorge
#

Yes replace them and no you don't have to redeploy

round sluice
#

@west gorge we are still encountering this with trying several RPCs (paid and not paid), interval is set to 2 seconds, it works when using UNITY editor (we get events) but when we deploy to webgl with Build and Run - and then look at console in Chrome we never see our logging and never receive events

#

we should see a MapCreated event

#

should the wss be blank in the project settings so that polling is used?

west gorge
#

Hi @round sluice sorry to hear that, for WebGL builds you'll have to force event polling, set it to true/ticked on the EventServiceAdapter Web Sockets have an issue working on WebGL because WebGL doesn't truly support async

round sluice
#

it is set to True - but we still have the issue

#

@west gorge

west gorge
#

Hi @round sluice this is working for me, please follow the documentation here if the issue still persists create an issue based on the bug template (with repro steps, with a fresh clone in an empty project) and assign it to me, rob1997

Often, you will want to react to certain events happening on the blockchain. For example, you might want to know when a transfer of funds occurs on a specific smart contract.

GitHub

🕹 Unity SDK for building games that interact with blockchains. - Issues · ChainSafe/web3.unity

round sluice
#

@west gorge ok ill work on making an issue

#

right now we are not blocked on dev because we can do it in unity editor but deployment to web we will be blocked