Library
Assume ContractA
imports LibraryA
, when deploying ContractA
, LibraryA
is embedded into ContractA
if LibraryA
contains only internal
functions.
If LibraryA
contains at least one external
function, LibraryA
must be deployed first, and then linked when deploying ContractA
.
ref:
https://solidity-by-example.org/library/
https://docs.soliditylang.org/en/v0.7.6/using-the-compiler.html
Foundry
In Foundry tests, Foundry will automatically deploy libraries if they have external
functions, so you don't need to explicitly link them.
hardhat-deploy
Whenever the library is changed, hardhat-deploy will deploy a new implementation and upgrade the proxy:
ref:
https://github.com/wighawag/hardhat-deploy#handling-contract-using-libraries