Contract Events
You can listen to events that are emitted by a contract.
This is useful when you want real-time updates of events happening on the blockchain.
The names of the events are the same as the events emitted from the smart contract.
For pre-built contracts, you can inspect the source code to see the events that are emitted in each function call.
Below are some examples:
Event Name | Description | Source Code |
---|---|---|
TokensClaimed | Token claimed by a wallet from a Drop contract | Smart Contract Code |
TokensMinted | Token minted by a wallet into a NFT / Token contract | Smart Contract Code |
ListingAdded | New listing created in a marketplace contract | Smart Contract Code |
Listen to All Events
Listen to all events emitted by the contract.
- React
- Javascript
- Python
- Go
contract.events.listenToAllEvents((event) => {
console.log(event.eventName) // the name of the emitted event
console.log(event.data) // event payload
}
contract.events.listenToAllEvents((event) => {
console.log(event.eventName) // the name of the emitted event
console.log(event.data) // event payload
}
Python SDK support for listenToAllEvents is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for listenToAllEvents is coming soon.
Want this feature sooner? Let us know in Discord!
Listen to a Specific Event
Listen to all occurrences of a specific event.
- React
- Javascript
- Python
- Go
contract.events.addEventListener("TokensMinted", (event) => {
console.log(event);
});
contract.events.addEventListener("TokensMinted", (event) => {
console.log(event);
});
Python SDK support for addEventListener is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for addEventListener is coming soon.
Want this feature sooner? Let us know in Discord!
Listen to Transactions
Listen to all transactions in their raw form.
- React
- Javascript
- Python
- Go
contract.events.addTransactionListener((event) => {
console.log(event);
}
contract.events.addTransactionListener((event) => {
console.log(event);
}
Python SDK support for addTransactionListener is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for addTransactionListener is coming soon.
Want this feature sooner? Let us know in Discord!
Remove All Listeners
- React
- Javascript
- Python
- Go
contract.events.removeAllListeners();
contract.events.removeAllListeners();
Python SDK support for removeAllListeners is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for removeAllListeners is coming soon.
Want this feature sooner? Let us know in Discord!
Remove an Event Listener
- React
- Javascript
- Python
- Go
contract.events.removeEventListener("TokensMinted", (event) => {
console.log(event);
});
contract.events.removeEventListener("TokensMinted", (event) => {
console.log(event);
});
Python SDK support for removeEventListener is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for removeEventListener is coming soon.
Want this feature sooner? Let us know in Discord!
Remove a Transaction Listener
- React
- Javascript
- Python
- Go
contract.events.removeTransactionListener((event) => {
console.log(event);
}
contract.events.removeTransactionListener((event) => {
console.log(event);
}
Python SDK support for removeTransactionListener is coming soon.
Want this feature sooner? Let us know in Discord!
Go SDK support for removeTransactionListener is coming soon.
Want this feature sooner? Let us know in Discord!