Skip to main content
Version: 2.2

Track Specific CryptoPunk NFTs by Token IDs

Lets create a stream that monitor specific CryptoPunk NFTs based on an array of Token IDs.

Programmatically​

const punkTransferAbi = [
{
anonymous: false,
inputs: [
{ indexed: true, name: "from", type: "address" },
{ indexed: true, name: "to", type: "address" },
{ indexed: false, name: "punkIndex", type: "uint256" },
],
name: "PunkTransfer",
type: "event",
},
]; // valid abi of the event

const options = {
chains: [EvmChain.ETHEREUM], // list of blockchains to monitor
description: "1000 to 1002 cryptopunks", // your description
tag: "cryptoPunks", // give it a tag
abi: punkTransferAbi,
includeContractLogs: true,
topic0: ["PunkTransfer(address,address,uint256)"], // topic of the event
advancedOptions: [
{
topic0: "PunkTransfer(address,address,uint256)",
filter: { in: ["punkIndex", ["1000", "1001", "1002"]] }, // only receive transfer events if the token id is 1000/1001/1002
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: "0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB", // crypto punks 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": "PunkTransfer(address,address,uint256)",
"filter": { "in": ["punkIndex", ["1000", "1001", "1002"]] }
}
]
  1. Click on create stream button.