Skip to content

How to deploy contract with linked libraries or get contract factory in hardhat-viem #4626

Discussion options

You must be logged in to vote

Had the same problem. I've submitted the following PR that will provide such support. However, for now I can only suggest copy pasting the code as a workaround and parse the bytecode on your own.

You will need this function.

export async function resolveBytecodeWithLinkedLibraries(
  artifact: Artifact,
  libraries: Libraries<viemT.Address>
): Promise<string>;

Once you have it you will only need to parse bytecode and deploy it using deployContract.

const artifact = await hre.artifacts.readArtifact(
  contractName,
);
const publicClient = await hre.viem.getPublicClient();
const [client] = await hre.viem.getWalletClients();
const hash = await client.deployContract({
  abi: artifact.abi,
  b…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Aliceonly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants