What is the difference between these two?



both of them are giving me the same result on remix. Why?

So is this:



Am I missing something. Is there security consideration in using one of these?

1 Answer 1


Those are not "two methods". When you do address(_instance) or address(this) what you are doing is casting the _instance/this object into the type address.

Casting means taking an object of a certain data type and converting it into another data type.

For example, if you had a uint8 number and you wanted to do a power operation with it, given that uint8 would not have the capacity to hold a very large number, you would first cast it into a bigger int like this: uint256(number)

In your example above, you are taking a contract object and casting it into an address, which basically gives you the address of the contract.

  • 1
    So both of them are the same and there is nothing to be bothered about? Commented Dec 29, 2017 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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