Let’s create a stream that monitors all the NFT contract transfers from a specific sender address.
This stream uses the listen to all addresses feature that is available only on Business and Enterprise plans.
There will be a few NFT contracts that don’t follow the standards like CryptoPunks that have a different ABI, and you will not receive webhook requests from those non-standard NFT contracts.
You will use the ABI specific to NFT transfers, the one that has indexed for tokenId.
Programmatically
const NFT_transfer_ABI = [{
"anonymous": false,
"inputs": [
{ "indexed": true, "name": "from", "type": "address" },
{ "indexed": true, "name": "to", "type": "address" },
{ "indexed": true, "name": "tokenId", "type": "uint256" },
],
"name": "transfer",
"type": "event",
}]; // valid abi of the event
const options = {
chains: [EvmChain.ETHEREUM], // list of blockchains to monitor
description: "monitor all NFT transfers", // your description
tag: "NFT_transfers", // give it a tag
abi: NFT_transfer_ABI,
includeContractLogs: true,
allAddresses: true,
topic0: ["Transfer(address,address,uint256)"], // topic of the event
advancedOptions: [
{
topic0: "Transfer(address,address,uint256)",
filter: { "eq": ["from", "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5"] }, // only receive NFT transfer events from this address
},
],
webhookUrl: "https://YOUR_WEBHOOK_URL", // webhook url to receive events,
};
const stream = await Moralis.Streams.add(options);
Via WebUI
- Create a new Stream
- Fill out the form
- Switch on Event Emittance and Add the Abi and select the topic
- Select
Listen to all addresses and Contract interactions (logs)
- Add below value to advanced options
[{
"topic0": "Transfer(address,address,uint256)",
"filter": { "eq": ["from", "0x283af0b28c62c092c9727f1ee09c02ca627eb7f5"] }
}]
- Click on create stream button