Last active
March 11, 2023 11:17
-
-
Save thatguyintech/b525ea093cc4d624f61927392db834cf to your computer and use it in GitHub Desktop.
Revisions
-
ALBERT revised this gist
Mar 23, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const zeroTopic = "0x00000000000000000000000000000000000000000000000000000000000 const nftContractAddress = "0xbd34d145fcfd3992a0def1057891d51339a90128"; // Initialize alchemy-web3 object. // Docs: https://docs.alchemy.com/alchemy/documentation/subscription-api-websockets const web3 = createAlchemyWeb3( `wss://eth-rinkeby.ws.alchemyapi.io/ws/${alchemyApiKey}` ); -
ALBERT created this gist
Mar 23, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ // watch-for-mints.js // npm install @alch/alchemy-web3 const { createAlchemyWeb3 } = require("@alch/alchemy-web3"); // TODO: Replace this with your key. const alchemyApiKey = "your api key"; // NFT mints emit Transfer events with "from" set to 0x0. // This is the "transfer event" topic we want to watch. const mintTopic = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"; // This is the "from address" we want to watch. const zeroTopic = "0x0000000000000000000000000000000000000000000000000000000000000000"; // This is the NFT contract we want to watch. const nftContractAddress = "0xbd34d145fcfd3992a0def1057891d51339a90128"; // Initialize alchemy-web3 object. const web3 = createAlchemyWeb3( `wss://eth-rinkeby.ws.alchemyapi.io/ws/${alchemyApiKey}` ); // Create the log options object. const hackrDaoMintEvents = { address: nftContractAddress, topics: [mintTopic, zeroTopic] } // TODO: Add whatever logic you want to run upon mint events. const doSomethingWithTxn = (txn) => console.log(txn); // Open the websocket and listen for events! web3.eth.subscribe("logs", hackrDaoMintEvents).on("data", doSomethingWithTxn);