0

If I modularise a contract into two contracts, and inherit one of them instead using a monolithic approach, will the deployment costs be larger with two contracts or is the cost the same as with the monolithic approach?

1

Let's try.

Monolithic

pragma solidity ^0.5.0;

contract A {
    function doIt() public {
    }
    function doOther(uint value5) public {
    }
}

39293 gas

Inheritance

pragma solidity ^0.5.0;

contract A2 {
    function doIt() public {
    }
}

contract B2 is A2 {
    function doOther(uint value5) public {
    }
}

39293 gas when deploying contract B2.

This is because in reality the compiler flattens the contracts before compiling them. So the end result will actually look like contract A in both cases.

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.