Is a reliable way to identify the caller with the following code?
bool isContract = msg.sender != tx.origin;
Is a reliable way to identify the caller with the following code?
bool isContract = msg.sender != tx.origin;
This should work. Also you can check the size of the code in the address if it is bigger than zero, is a contract
function isContract(address addr) returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
Hope this helps you
tx.originmay also stop working in future Ethereum versions, especially as account abstraction work comes in. – user19510 Jan 05 '19 at 21:55