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?

1 Answer 1

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/

2
  • Thank you for the help. How were you able to find that it was using a proxy?
    – vizzi
    Nov 26, 2021 at 20:49
  • 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. Nov 26, 2021 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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