Skip to main content
Version: Endpoint V1

IERC165 OFT Interface Ids

Use these interface ids to determine which version of OFT is deployed.

  • OFT(v1): 0x14e4ceea
  • OFTV2: 0x1f7ecdf7
  • OFTWithFee: 0x6984a9e8
interface ERC165 {
/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
info

This method is no longer directly available within LayerZero V2 OFTs. Instead, a custom versioning has been applied within both V2 OApp and OFT.

Example Hardhat Task

module.exports = async function (taskArgs) {
const OFTInterfaceId = 0x14e4ceea;
const OFTV2InterfaceId = 0x1f7ecdf7;
const OFTWithFeeInterfaceId = 0x6984a9e8;

const ERC165ABI = ['function supportsInterface(bytes4) public view returns (bool)'];

try {
const contract = await ethers.getContractAt(ERC165ABI, taskArgs.address);
const isOFT = await contract.supportsInterface(OFTInterfaceId);
const isOFTV2 = await contract.supportsInterface(OFTV2InterfaceId);
const isOFTWithFee = await contract.supportsInterface(OFTWithFeeInterfaceId);

if (isOFT) {
console.log(`address: ${taskArgs.address} is OFT(v1)`);
} else if (isOFTV2) {
console.log(`address: ${taskArgs.address} is OFTV2`);
} else if (isOFTWithFee) {
console.log(`address: ${taskArgs.address} is OFTWithFee`);
} else {
console.log(`address: ${taskArgs.address} is not an OFT`);
}
} catch (e) {
console.log('supportsInterface not implemented');
}
};