0

When I use my custom library, Brownie complains that the library is not deployed (UndeployedLibrary). But why doesn't it complain about other library files like the ones inside OpenZeppelin?

For example, in the image below, it doesn't throw any error for EnumerableSet but it throws UndeployedLibrary for Strings2Bytes32 that is written by myself.

a contract dependent on some libraries

I know that if I deploy the Strings2Bytes32 once is enough to get rid of the error, but I don't understand the difference between these two library files.

  • What is the difference between these two?
  • Can I set up Brownie in a way that it treats my own library files like the ones inside OpenZeppelin?
3
  • Can you share the library source? OpenZeppelin libraries use "internal" functions, internal functions are inlined when compiling so they don't require the library to deployed and linked. From the description the library functions might be public or external.
    – Ismael
    Commented Mar 16, 2022 at 21:04
  • @Ismael Thank you! I didn't know that. It resolved my problem. Do you know where this behavior is mentioned in the solidity docs?
    – SSgumS
    Commented Mar 18, 2022 at 19:09
  • I've added a link to the documentation and an excerpt where the details is mentioned. I've learned it by trial an error.
    – Ismael
    Commented Mar 18, 2022 at 21:33

1 Answer 1

1

The explanation is in the libraries section.

Libraries can be seen as implicit base contracts of the contracts that use them. They will not be explicitly visible in the inheritance hierarchy, but calls to library functions look just like calls to functions of explicit base contracts (using qualified access like L.f()). [...]. To realize this in the EVM, code of internal library functions and all functions called from therein will at compile time be included in the calling contract, and a regular JUMP call will be used instead of a DELEGATECALL.

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.