polymath.js-deprecated
polymath.js-deprecated copied to clipboard
KYC Verification EOA Check
Allow an easy way for KYC providers to verify if an address being requested for verification is a EOA/contract address or not.
FYI - function to do this from web3 is: web3.eth.getCode
@adamdossa right. @Everhusk for checking so within Solidity it can be done like this:
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length>0);
}
@GregTheGreek please take a look at this when you have a chance.
@adamdossa @pabloruiz55 @ChainSafe Thoughts on adding this into template.js (wrapper)? That way we can just call web3.eth.getCode and all the contracts will have access?
Edit: Template.js, since there is no reason to add a constant or anything on solidity
What would be the logic if it is a contract address? There are some cases where I could imagine a KYC provider wanting to be able to whitelist an address (many current ICOs do allow this), although perhaps it may require some extra diligence, and possibly a higher fee (or this may not be feasible for current KYC approaches). Either way, I think if we do this check we could either just display it as information to the KYC provider, but I don't think we want to hardcode disallowing contract addresses at the Solidity end.
I guess that the idea is to at least give the KYC provider some quick info about the address. It would be up to them to decide if they don't want to approve a contract address.
We can't ban it from the get-go as an address containing code could be a multsig wallet. There's also the case of forbidding a contract address, as it could be an investment pool contract trying to get into an STO.
I see no problem in adding that function to the wrapper, but we have to be very careful in how we allow people to use it.
It's gonna be a v1 stretch goal - 100% for v2.