I'm trying to find what the benefit is of a library. I found the following statements. (Please correct me if i'm wrong)

  • Cost less gas to deploy
  • Uses the storage of the calling contract
  • the library and contract are compiled separately but the library gets linked into the contract as a part of it when deploying.

The major downside I see of a library is that it's a part of the contract. Meaning if I want to update the library I need to redeployed I also need to redeployed the linked contract. If the library was just a plain contract I only need to redeploy that contract and set the reference again to the other contract.

contract Lib {
    //Some code

contract A {

    Lib someLib;

    function setLibReference(address libAddress) public {
        someLib = Lib(libAddress);

For me this seems as a major downside or am I wrong in this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.