Skip to main content

How to monitor ENS Domain Registrations

Programatically

const ensNameRegisteredAbi = [{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "name",
"type": "string",
},
{
"indexed": true,
"internalType": "bytes32",
"name": "label",
"type": "bytes32",
},
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address",
},
{
"indexed": false,
"internalType": "uint256",
"name": "cost",
"type": "uint256",
},
{
"indexed": false,
"internalType": "uint256",
"name": "expires",
"type": "uint256",
},
],
"name": "NameRegistered",
"type": "event",
}]; // valid abi of the event

const filter = {
"and": \[
{ "eq": ["owner", "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5"] },
{ "gt": ["cost", "1000000000000000000"] },
],
}; // only receive registration events if the owner is the address and the cost is higher than 1 ETH

const options = {
chains: [EvmChain.ETHEREUM], // Ethereum Name Service so we only monitor Ethereum
description: "ENS Name Registrations", // your description
tag: "ensRegistrationByBob", // give it a tag
abi: ensNameRegisteredAbi,
topic0: ["NameRegistered(string,bytes32,address,uint256,uint256)"],
includeContractLogs: true,
advancedOptions: [
{
topic0: "NameRegistered(string,bytes32,address,uint256,uint256)",
filter,
includeNativeTxs: true,
},
],
webhookUrl: "<https://YOUR_WEBHOOK_URL>", // webhook url to receive events,
};

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

const { id } = stream.toJSON(); // { id: 'YOUR_STREAM_ID', ...stream }

// Attach the contract address to the stream
await Moralis.Streams.addAddress({
id,
address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", // ENS Registry address
});

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. Add below value to advanced options
[
{
"topic0": "NameRegistered(string,bytes32,address,uint256,uint256)",
"filter": {
"and": [
{ "eq": ["owner", "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5"] },
{ "gt": ["cost", "1000000000000000000"] }
]
}
}
]
  1. Click on create stream button.