0

I know that my question is probably funny, but I need to understand the deployment workflow more deeply.

As many people use OpenZeppelin, I am not an exception. I imported the file into my contract and in Remix I see a few contracts to deploy(see image). Locally, I always deploy only my contract, and it works perfectly, but what about live development? As far as I understood, I will deploy all OpenZeppelin contracts along with my, which cost an additional gas. Is that correct? What is the best/rational way to deploy contracts using external ones? enter image description here

Thanks,

1 Answer 1

1

The contracts use inheritance. So it goes something like A > B > C, where C inherits B and B inherits A.

Assuming the A, B and C are non-abstract contracts, you can deploy any one of them. If you deploy A, the resulting contract has A's functionality. If you deploy B, it has functionalities from A and B. And C has functionalities from A, B and C.

With inheritance, the contracts are flattened before deployment. So if you deploy B, A's functionality is included/flattened into the same contract, and therefore you only deploy one contract.

2
  • I am asking as I sometimes saw that people deployed 10 different contracts where only 1 was their own and rest of them were OpenZeppelin`s. I mean, you check any NFT contract in etherscan and inside "Contract" tab you can see 10 separate files instead of 1. Commented Jan 13, 2022 at 15:31
  • Yes, there can be multiple files which are used for compiling, but in bytecode there's just one contract. Commented Jan 13, 2022 at 15:37

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.