Reputation: 31
Is there a way to check if the ethereum address is valid in solidity? I think I might have found a way in web3js library on utils, but want to know if this method is possible on solidity.
And how can I use solidity to know the difference between account addresses and smart contract address?
Upvotes: 2
Views: 4029
Reputation: 83546
And how can I use solidity to know the difference between account addresses and smart contract address ?
You can use EXTCODESIZE
opcode.
function isContract(address _a) public returns (bool) {
uint size;
assembly {
size := extcodesize(_a)
}
return size > 0
}
Upvotes: 2