Discover more from Degen Code
Public Websocket RPC for Avalanche
Moralis is Dead, Long Live Moralis!
Sadly, Moralis has discontinued their SpeedyNode service, which I wrote about it the guide to using a 3rd Party RPC.
I looked through the Avalanche documentation this evening and discovered that they offer a public RPC websocket endpoint at
The websocket RPC has a limitation, however. It only supports the API methods not already exposed over their HTTP endpoint. We want access to
eth_subscribe, which allows us to subscribe and receive events and new blocks. The wrinkle is that the websocket endpoint supports
eth_subscribe but none of the usual APIs like
eth_call that allow you to send transactions and get balances, etc. So you can’t use this as an all-in-one replacement for Moralis.
I use Brownie to execute transactions, but manage the listener subscriptions directly using asyncio and the
websockets library. This allows me to take a hybrid approach with my RPCs, at the cost of maintaining two connections.
If you want to try this for yourself, set an HTTP RPC for your Brownie network, and use the websocket RPC for the subscription.
You can even mix endpoints from different services, if you want.
As an example, you can take the previous multi-pool prediction bot and set the following values:
BROWNIE_NETWORK = "avax-main" # or ankr-avax-main RPC_URI = "wss://api.avax.network/ext/bc/C/ws"
The performance may not be as good as a premium endpoint, but many of you have asked about free options so there you go.
Degen Code is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.