1

I am checking if an address is a smart contract. Similarly to many articles and example-codes out there, i do this within my function:

uint32 size;
assembly{
    size := extcodesize(_to)
}
if(size > 0){}

However, when I do this, as so many others seem to do, I get this error:

security/no-inline-assembly: Avoid using Inline Assembly.

I seem to struggle to find a solution to this. Even in the solidity 0.5.0 documentation they describe inline assembly, so seems weird that it is not allowed. Has anyone else encountered this, and found a solution to it?

1

If you're using Remix, this should only give you the following warning, not an error. It gives you an idea as to why you should avoid assembly (presumably unless you know what you're doing).

The Contract uses inline assembly, this is only advised in rare cases. Additionally static analysis modules do not parse inline Assembly, this can lead to wrong analysis results.

If you're using solc directly, then I think you'll need to play around with the solhint configuration, specifically under the Security Rules section. (See the no-inline-assembly rule.) You should be able to set it to 'false'. (Though on your head be it.)

For your specific piece of code, you need to be careful - it might not do what you expect it to do. See the Consensys Best Practices for why:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.