I would like to deploy a contract that has external library dependencies that need to be dynamically linked. This is typically done in hardhat ethers as follows:
const MyLibrary = await ethers.getContractFactory("MyLibrary");
const myLibrary = await MyLibrary.deploy();
await myLibrary.deployed();
// Deploy MyContract, linking MyLibrary library
const MyContract = await ethers.getContractFactory("MyContract", {
libraries: {
MyLibrary: myLibrary.address,
},
});
const myContract = await MyContract.deploy();
await myContract.deployed();
Does Foundry provide built-in support for dynamical library linking in Solidity? I want to deploy a contract to my local foundry node to be able to test it, though I'd imagine the solution if one exists would also be applicable to deploying contracts to live networks.
This question is somewhat related to the following but there isn't a satisfactory answer:
How to link a library to a smart contract using Foundry
How to deploy a contract with linked libraries and a different version in foundry test