The original sketch tried to permit a target call only when the caller advertised a chosen ERC165 interface. That can detect a claimed capability, but it cannot establish that the caller is an authorized instance. Any other contract can return true for the same identifier.
The historical sketch
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
interface IYourContract {
function fSubmitRequest(bytes calldata _pData) external;
// ERC165: Add a function to expose interface detection
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import "./interfaces/IYourContract.sol";
contract YourContractImpl is IYourContract {
TargetContract public target;
// Implement ERC165's supportsInterface
function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
return interfaceId == type(IYourContract).interfaceId;
}
// Logic call the target contract
function fSubmitRequest(bytes calldata _pData) external override {
......LOGIC HERE......
target.fSubmit(_pData);
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import "./interfaces/IYourContract.sol";
contract TargetContract {
/// @notice Logic
function fSubmit(bytes calldata _pData) external {
require(_onlyIYourContract(_msgSender()), "Invalid caller");
......LOGIC HERE......
}
/// @notice Check if the caller is allowed
function _onlyIYourContract(address account) private view returns (bool) {
(bool success, bytes memory data) = account.staticcall(
abi.encodeWithSelector(0x01ffc9a7, type(IYourContract).interfaceId) // 0x01ffc9a7 is ERC165.supportsInterface.selector
);
if (!success || data.length < 32) return false;
return abi.decode(data, (bool));
}
}
These fragments include explicit omitted logic, a missing context helper, and incomplete contract wiring. They are not a compilable application.
A claim is not an identity
A target that relies only on supportsInterface lets a caller assert its own eligibility. Authorization needs a separate rule that identifies who may act, such as an explicitly trusted instance or role established by the application’s authority model. Interface support may be an additional compatibility check.
The implementation also does not advertise ERC165’s own interface ID. The low-level call shown is not the standard’s complete detection procedure, does not impose its query gas bound, and can still revert on malformed ABI data despite checking the returned byte length.
The interface-ID note explains what the identifier represents. No contracts were compiled, queried, deployed, or authorized by this rewrite.