Getting Ethereum amount from Ethers.js Contract Transfer Event

Getting Ethereum amount from Ethers.js Contract Transfer Event

Manage alerts

Loading saved threads...

Tyler Pashigian · External communityPost link
External question — Ethereum Stack Exchange Author: Tyler Pashigian Original post: https://ethereum.stackexchange.com/questions/113378 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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" } ] }
Quote
Report
DrGorilla.eth · External communityPost link
External answer — Ethereum Stack Exchange Author: DrGorilla.eth Original post: https://ethereum.stackexchange.com/a/113381 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Rather listen for the ordersMatched event, which include a price param (see the 3d log event: https://etherscan.io/tx/0x49a1b9af049ff10cc8e61ad49499c3615b1455a33c9cda6cc0390142d0058281#eventlog or the actual event in wyvernEngine : https://etherscan.io/address/0x7be8076f4ea4a4ad08075c2508e481d6c946d12b#code line450).
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Ethereum Stack Exchange Author: Tyler Pashigian Source score (net votes, not local likes): 3 Original post: https://ethereum.stackexchange.com/questions/113378 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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" } ] }

Cancel quote

Checking account access…