Handling Multiple ABI Signatures to Retrieve Contract Information

Hello,

I’m retrieving all newly deployed contracts on Uniswap V2 & V3, and I’ve encountered a problem related to differences between contract versions. I’m using a standard ABI:

const erc20Abi = [ "function name() public view returns (string memory)", "function symbol() public view returns (string memory)", "function owner() public view returns (address)", "function decimals() public view returns (uint8)", "function totalSupply() public view returns (uint256)", "function balanceOf(address account) public view returns (uint256)", ];

However, some contracts have this signature:

function name() public pure returns (string memory)

Due to the presence of “pure”, I can’t call it using the standard ABI. I’m currently using the ethers library with Infura. What’s my best approach to call a function without the same signature and make calls that are compatible with all contracts?

2 Likes

Hi @zonixo,

do you still have a problem with this? You should be able to do the call OK?

Please let us know exactly what you are calling and a snip of code to show how.

1 Like

Hello,

I’ve identified the main problem. It pertains to the function named ‘owner()’. This function is not always implemented under this name and isn’t a part of the standard ABI.

I examined the bytecode and all the functions implemented, then modified the ABI accordingly.

All good thanks :slight_smile:

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.