Subscriptions | Avalanche

Subscriptions are a feature of the Avalanche JSON-RPC API that allows developers to receive real-time updates on various blockchain events. Developers can subscribe to specific events of interest, such as new block headers, pending transactions, or contract events.

📘

Note that all subscriptions require a WebSocket connection.

Native EVM subscriptions

Developers can use the following native methods to subscribe to events:

The subscriptions created can be cleared using the following method:

web3.js subscriptions

The web3.js library also offers subscription methods. web3.js subscriptions are the successors of the deprecated web3.eth.filter methods and provide a way for developers to receive real-time updates about events on the blockchain without constantly polling the blockchain for new data.

Subscriptions can be created using one of the following methods:

The subscriptions created can be cleared using the following method: