Skip to main content

removeEventListener

Remove an event listener from a contract, such as one created with addEventListener.

Usage

Provide the name of the event to remove the listener from, and the listener function itself.

contract.events.removeEventListener("TokensMinted", (event) => {
console.log(event);
});

Configuration

eventName

The name of the event to remove the listener from.

Use the name of the event as it appears in the contract.

contract.events.removeEventListener(
"TokensMinted",
(event) => {}, // Perform some logic
);

listener

The listener to unregister.

This must be the same function that was passed to addEventListener.

// For example, if you registered a listener like this:
contract.events.addEventListener("TokensMinted", (event) => {
console.log("Hello World!");
});

// You must unregister it like this, by providing the same function.
contract.events.removeEventListener("TokensMinted", (event) => {
console.log("Hello World!");
});