Suppose a contract has been deployed and I don't have its source code or ABI. From web3, I would like to know if the contract has a method with a given signature. (An example application would be a blockchain service that responds to requests by invoking a specific callback method on the calling contract, like Oraclize.)
I can get close with the following:
methodSignature = web3.sha3('methodName(bytes32,bytes)');
calltx = {
to: TARGET_ADDR,
data: methodSignature.substring(0,10)
};
let result = web3.eth.call(calltx)
and then if result is not '0x' then the method exists because it returned some value. But '0x' doesn't mean the method doesn't exist, depending on the method itself. How do I tell the difference?