Suppose we have a contract Foo and another contract Bar that receives the address of some instance of Foo in its constructor.

Is there a difference (in functionality or gas usage) between doing:

function Bar(address _foo) public {
  foo = Foo(_foo)


function Bar(Foo _foo) public {
  foo = _foo
  • They produce the exact same EVM byte code. However, the compiler checks the ABI if you use contract type instead of address type Apr 5, 2018 at 21:20

1 Answer 1


Functionally: no difference.

Gas usage: no difference.

You can think of static types as hints for the compiler. At run-time, there is no difference.

You can easily verify/trace this in remix with this code:

contract X {
    uint x = 100;

    function doSomething() public {

contract Y {
    function a(address _x) public {
        X x = X(_x);

contract Z {
    function a(X _x) public {
        X x = _x;

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.