I created a script to accept a contract address and watch that contract for specific "events." In this case, I want to check each time the Loot for Snail function is invoked on the EvoSnails NFT contract.
As you can see in the transactions, the method has been called quite a few times and it shows on the contract tx list. However, when I try to run my script to check for this event, the event does not exist in the contract.
A snippet of my code, which checks the Contract ABI for it's events and functions is here:
async function getContractABI(contractAddress) {
let opts = {
url: `http://api.etherscan.io/api?module=contract&action=getabi&address=${contractAddress}&apikey=${etherscanApiKey}`,
responseType: 'json'
}
try {
let response = await got(opts);
const contractABI = JSON.parse(response.body.result);
return contractABI;
}
catch (e) {
console.log(e);
}
}
const getContractEvents = async (contractAddress) => {
let contractABI = await getContractABI(contractAddress);
let contractEvents = contractABI.map(i => {
// i.type would be event but it doesn't appear for event or 'function'
if (i.type === 'event'){
return i.name;
}
})
var results = contractEvents.reduce((results, item) => {
if (typeof item === 'string') results.push(item) // modify is a fictitious function that would apply some change to the items in the array
return results;
}, [])
return results;
}
getContractEvents("0x8a6e948a30ee8cb1391712710c1c59be553ab008");
As you can see, Loot for Snail is not here. How would I be able to monitor for this specific function when it is called?