Use ERC165Checker library function in web3

As I understand the ERC165Checker library provides the _supportsInterface function which takes a contract address and an interfaceId and returns whether that contract has the specific functions. How can I call this function in js with web3?

Hi, welcome! :wave:

If you use web3.js, I thinkw it should be:

let ERC165Checker = new web3.eth.Contract(ContractABI, ERC165ContractAddress);

let isSupported = ERC165Checker.methods.supportsInterface(Contract_Address, interfaceId);
console.log("support this interface", isSupported);

Hi @Toth_Levente. There is no way to use this out of the box in JavaScript. The code that @Skyge shared would not work because 1) ERC165Checker is a library, and 2) the function is internal.

So you will need to reproduce the logic in _supportsInterface using web3.js RPC calls. You can also just implement the spec from ERC165.

1 Like

Ohhhhh, my bad, thanks for correct me.

1 Like