1

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");

This is the result from the script.

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?

New contributor
vizzi is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
0

The contract deployed at 0x8a6e948a30ee8cb1391712710c1c59be553ab008 is the OpenZeppelin TransparentUpgradeableProxy proxy (the original implementation of your NFT contract is here: 0x9539EAC4e19d0627815b166330b83f9c931A9e88

It means that you should listen to transaction to/from the proxy (0x8a6e) using the abi from the original contract (0x9539).

Check the Openzepellin post for additional details : https://blog.openzeppelin.com/the-transparent-proxy-pattern/

4
  • Thank you for the help. How were you able to find that it was using a proxy?
    – vizzi
    yesterday
  • If you check on etherscan the 0x8a6e address, you can see the contract name (TransparentUpgradeableProxy) as well as the "Read as Proxy" tab (etherscan.io/address/…) where you'll find the address of the original/target contract. yesterday
  • If it answers your question, please mark it as "accepted answer" yesterday
  • Yep. Thanks so much for your help.
    – vizzi
    yesterday

Your Answer

vizzi is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.