Let's take two addresses:

The first one is a liquidity pool that implements IPancakePair interface and the second one is a IERC20 token.

Short of inspecting the name, how can I differentiate the two programmatically?

I have for IPancakePair and IERC20.

  • Why do you want to differentiate them? Usually LP are ERC20. There's no EIP standard for LP, any possible difference is at most a weak one. It should be trivial to write an LP that doesn't have any difference from a regular ERC20 token.
    – Ismael
    Commented May 20, 2021 at 1:36

1 Answer 1


The simplest way is to check if code implements interface of PancakePair or IERC20.

The way to do is that you need to pull the code using and then check if it contains signature of every method in the interface, e.g.

const matchSignature = (
  web3: Web3Type,
  code: string,
  abi: $ReadOnlyArray<Object>,
) => {
  const contract = new web3.eth.Contract(

  return contract.options.jsonInterface.every((token) => {
    return !token.signature || code.includes(token.signature.slice(2));

Your Answer

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

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