Skip to main content

Don't have an API key yet?

Sign-up to Moralis to get your free API key and start building today.

Get Your Free API Key
Version: 2.0

How to listen all events from a contract factory

Let's create a stream that monitors all the events specific to a contract factory.

info

This stream uses listen to all addresses feature that is available only on Business and Enterprise plans.

info

You will need an ABI that is used only on your contracts in order to not receive the events from other contracts that use the same ABI.

Programmatically

const Contract_Factory_ABI = [{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "from", "type": "address" },
{ "indexed": true, "name": "to", "type": "address" },
{ "indexed": true, "name": "contract", "type": "address" },
],
"name": "factoryEvent",
"type": "event",
}]; // valid abi of the event

const options = {
chains: [EvmChain.ETHEREUM], // list of blockchains to monitor
description: "monitor a contract factory", // your description
tag: "contract_Factory", // give it a tag
abi: Contract_Factory_ABI,
includeContractLogs: true,
allAddresses: true,
topic0: ["factoryEvent(address,address,address)"], // topic of the event
webhookUrl: "https://YOUR_WEBHOOK_URL", // webhook url to receive events,
};

const stream = await Moralis.Streams.add(options);


Via WebUI

  1. Create a new Stream
  2. Fill out the form
  3. Switch on Event Emittance and Add the Abi and select the topic
  4. Select Listen to all addresses and Contract interactions (logs)
  5. Click on create stream button.