Handling Multiple ABI Signatures to Retrieve Contract Information

Hello,

I don’t know if this is the right place to ask my question.

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 providing a standard ABI like below :

function name() public view returns (string memory)

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 retrieve the ABI and make calls that are compatible with all contracts?

I want to be able to call any name function if exist no matter the signature.

1 Like

Have you actually tried it?

There shouldn’t be any problem doing so, since the function selector (function name + argument types by order) is identical in both cases.

If there is a problem, then please share the details (error-message, etc), so that we can refer to it.

This is not the right place for Solidity support questions. Please Read this before posting.

This is not the place for…

To call the name() function, regardless of the modifier, maybe you can use the ethers library along with a try-catch mechanism. Please let me know if I’ve misunderstood. I’m still learning.