Is a reliable way to identify the caller with the following code?
bool isContract = msg.sender != tx.origin;
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityThis 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.origin
may also stop working in future Ethereum versions, especially as account abstraction work comes in.