我知道我可以跟踪智能合同的事件,比如Transfer和Approval ( ERC20和ERC721 ),甚至ApprovalForAll ( ERC721 )。
我还知道,对于我部署的任何智能契约,我都可以跟踪自己定义的事件。
但是,是否有一种方法来跟踪NFT的销售,比方说,OpenSea?
我希望,如果我知道OpenSea托管智能合同(或任何其他市场)的地址,我就有可能知道:
Transfer事件--这意味着“发布销售”)Transfer事件从该托管市场到一个与原始地址不同的地址这有意义吗还是我没看到什么?
发布于 2023-03-18 08:37:35
下面是一个示例代码,说明如何使用Moralis streams API跟踪智能契约上的NFT传输事件。
import Moralis from "moralis";
const addStream = async () => {
if (!Moralis.Core.isStarted) {
await Moralis.start({
apiKey: process.env.API_KEY,
});
}
const options = {
webhookUrl: "...", // Stream data will be sent to this webhook url
description: "NFTTransfers",
tag: "transfers",
topic0: ["Transfer(address,address,uint256)"], // topic0 of your tracking
allAddresses: false,
includeNativeTxs: false,
includeContractLogs: true,
includeInternalTxs: false,
getNativeBalances: [],
triggers: [],
abi: [
{
// ... Paste ABI as value
},
],
advancedOptions: null,
chainIds: ["0x1", "0x5"], // chains on which you want to track events
};
const stream = await Moralis.Streams.add(options);
// Attach the contract address to the stream
await Moralis.Streams.addAddress({
id: stream.raw.id,
address: "0x..", //contract address on which you want to listen to streams to
});
};
addStream();从流接收的数据将包含来自NFT事务的日志,您可以使用该日志来验证市场地址。
附注:我在莫拉利斯工作
https://ethereum.stackexchange.com/questions/147536
复制相似问题