0

I am writing tests for my contract in typescript. I am deploying the contracts like this:

import { Contract } from "../typechain-types/index";
import ContractArtifact from "../artifacts/contracts/Contract.sol/Contract.json";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { ethers, waffle } from "hardhat";


let contractOwner: SignerWithAddress;
let deployedContract: Contract;

const { deployContract } = waffle;
[contractOwner] = await ethers.getSigners();
deployedContract = (await deployContract(
        contractOwner,
        ContractArtifact
      )) as Contract;

Is it possible to set constructor arguments when deploying with typescript? If so, how?

1 Answer 1

1

From your code snippet I see you are using waffle's function deployContract, it receives 3 arguments:

  • wallet to send the deploy transaction

  • contract information (abi and bytecode)

  • contract constructor arguments

Just include the array of arguments at the end:

deployedContract = (await deployContract(
        contractOwner,
        ContractArtifact,
        [argument1, argument2,...,last argument]
      )) as Contract;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.