Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isContract will always return true #2

Closed
tymat opened this issue Mar 31, 2017 · 3 comments
Closed

isContract will always return true #2

tymat opened this issue Mar 31, 2017 · 3 comments

Comments

@tymat
Copy link

tymat commented Mar 31, 2017

The extcodesize(address) will return 1 when called against an externally owned account.

I modified isContract() to return the value of length.

truffle(test)> InterfaceAssetVendor.at(InterfaceAssetVendor.address).isContract.call(InterfaceAssetVendor.address)
[ true, { [String: '7333'] s: 1, e: 3, c: [ 7333 ] } ]
truffle(test)> InterfaceAssetVendor.at(InterfaceAssetVendor.address).isContract.call('0x94a69c2543edbb1efef8b6994bc8d0d5b5ffa641')
[ true, { [String: '1'] s: 1, e: 0, c: [ 1 ] } ]
@Dexaran
Copy link
Owner

Dexaran commented Apr 3, 2017

isContract will always return true

I don't understand what are you talking about.
isContract must return true if a given address is a contract and false if a given address is a wallet.

I wrote this small example:
contract ReturnTest {
bool public extCodeReturn=true;
function isContractTest(address _addr) {
uint length;
assembly { length := extcodesize(_addr) }
if(length>0) {
extCodeReturn=true;
}
else { extCodeReturn=false; } } }

I deployed it here on Ropsten: 0x8102d6c0CAc954BE65E60Eae602713c0c6e66f5D
When I'm executing isContractTest with 0x8102d6c0CAc954BE65E60Eae602713c0c6e66f5D address, it makes extCodeReturn = true.
When I'm executing isContractTest with 0x00b6fa39793d0537c111df8f6968204f152b4515 (my Ropsten address) it makes extCodeReturn = false. It looks like everything is ok.

@tymat
Copy link
Author

tymat commented Apr 3, 2017

For some reason this exact same code is returning false on TestRPC because the value that is returned from the below assembly is 1 when passed with a non contract address.

assembly { length := extcodesize(_addr) }

@izqui
Copy link

izqui commented Apr 13, 2017

Based on my testing, TestRPC is fucking up and returning size = 1 in call but in a full sendTransaction the internal value is 0.

I'm so confused by how this could be happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants