Skip to content

Commit

Permalink
add section for websocket event listener (#5619)
Browse files Browse the repository at this point in the history
### Description

a small section explaining how to set up a smart contract event listener using web3js and forno
  • Loading branch information
critesjosh authored Oct 28, 2020
1 parent d324a5c commit 50f1100
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/docs/developer-resources/forno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ Baklava = 'https://baklava-forno.celo-testnet.org'
Mainnet = 'https://forno.celo.org' or 'wss://forno.celo.org/ws' (for websocket support)
```

### Websocket connections & Event listeners

Websocket connections are useful for listening to logs (aka events) emitted by a smart contract, but Forno only allows a websocket connection for 20 minutes before disconnecting. On disconnect, you can reconnect to the websocket endpoint to keep listening. [Here](https://gist.github.com/critesjosh/a230e7b2eb54c8d330ca57db1f6239db) is an example script of how to set up an event listener that reconnects when the connection is broken.

0 comments on commit 50f1100

Please sign in to comment.