I am working on building a simple Twitter bot to tweet out sales that occur on an NFT's Smart Contract (https://etherscan.io/address/0xbd3531da5cf5857e7cfaa92426877b022e612cf8) by listening to the Transfer
event and tweeting out the information from the event subscription.
After following a tutorial in the Ethers.js docs (https://docs.ethers.io/v5/single-page/#/v5/api/contract/example/-%23-example-erc-20-contract--connecting-to-a-contract), it looks like I am able to see Transfer events output, but I am not sure how to get the actual Ethereum value (price) from the transaction. It looks like the parameters are to
, from
, and the mint number of the NFT collection.
I will post the event listened code, as well as the response. Please let me know if anyone knows what I am missing, thanks!
Event Listener
const abi = await getContractAbi();
const provider = new ethers.providers.WebSocketProvider(WSS_PROVIDER);
const contract = new ethers.Contract(CONTRACT_ADDRESS, abi, provider);
contract.on("Transfer", (from, to, amount, value, event) => {
console.log(JSON.stringify(value));
});
Output
{
"blockNumber": 13553616,
"blockHash": "0xa49016edacc2cdde0f49510fec7af16be42fd7d72f688b0a83f9afcb6d6dae39",
"transactionIndex": 214,
"removed": false,
"address": "0xBd3531dA5CF5857e7CfAA92426877b022e612cf8",
"data": "0x",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x00000000000000000000000046434f8f0b6d31a6a3ace9307077f5699eab2a08",
"0x00000000000000000000000044f63ba8637466015a8510dc40f384013d4dfbcc",
"0x000000000000000000000000000000000000000000000000000000000000018d"
],
"transactionHash": "0x49a1b9af049ff10cc8e61ad49499c3615b1455a33c9cda6cc0390142d0058281",
"logIndex": 483,
"event": "Transfer",
"eventSignature": "Transfer(address,address,uint256)",
"args": [
"0x46434f8f0b6d31A6A3aCe9307077F5699eab2a08",
"0x44f63bA8637466015A8510dc40f384013D4DfBcC",
{ "type": "BigNumber", "hex": "0x018d" }
]
}