Will adding OpenZeppelin Contracts as dependencies make our deployment more costly?

I wanted to know if I want to add a dependency that includes Openzeppelin’s contracts in my plain contract…
Suppose(SafeMath library or Initializable.sol)

Will the gas fee become higher now?
Will I have to deploy them and add their deployment cost in my overall project?

In that case, what is the benefit of using a library?

2 Likes

Hi @asmeedhungana,

Inheriting from and using contracts in OpenZeppelin Contracts means that the size of your contract will include the contracts that you use. Though if you want this functionality you would either need to use OpenZeppelin Contracts, another third party contract or implement yourself so this probably won’t make a big difference in your contract size and hence deployment cost.

The benefit is that OpenZeppelin Contracts already has created this functionality that you can use in community vetted code. You don’t need to develop this functionality yourself, saving a huge amount of time and decreasing security risks. Note: You still need to appropriately test and audit your solution.

What are openzeppelin-ethereum-smart-contracts for then? What it means for us besides that they’re pre-tested in the ethereum testnets and mainnet so we can rely on them for safe upgrading of our smart contracts?
I thought since they’re pre-deployed, we’d not have to deploy them again with our contracts!

1 Like

What do you mean by this @abcoathup? can you explain it to me more? :smiley:
Do you mean the openzeppelin-contracts package from your github?

1 Like

Hi @asmeedhungana,

OpenZeppelin Contracts Ethereum Package (v3) has a small number of deployed contracts:

You could create a proxy pointing to one of these logic contracts and you would have lower deployment costs.

OpenZeppelin Contracts doesn't currently have any deployed libraries.

If you want an ERC20 token or you want to add overflow checks then you can use this functionality from OpenZeppelin Contracts or you could create your own.

Either way there will need to be code in a smart contract to implement this functionality, so where appropriate for your needs, you are better to use OpenZeppelin Contracts.

2 Likes