1

I have TimeLock contract that extends TimelockController from OpenZeppelin contracts:

contract TimeLock is TimelockController {
 
  constructor(
    uint256 minDelay,
    address[] memory proposers,
    address[] memory executors,
    address admin
  ) TimelockController(minDelay, proposers, executors, admin) {}
}

I am using hardhat to deploy the contracts in which hardhat deploys TimeLock contract before it deploys Box contract. I am retrieving the TimeLock contract address in Box contract deploy script but it's showing error for transferOwnership(timeLock.address);

Property 'address' does not exist on type 'BaseContract'

const deployBox: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
    
    const { getNamedAccounts, deployments, network } = hre;
    const { deploy, log, get } = deployments;
    const { deployer } = await getNamedAccounts();
    
    log("Deploying Box ...");
    const box = await deploy("Box", {
        from: deployer,
        args: [],
        log: true,
    });

    const boxContract = await ethers.getContractAt("Box", box.address);
    const timeLock = await ethers.getContract("TimeLock");

    const transferOwnershipTx = await boxContract.transferOwnership(timeLock.address);
    await transferOwnershipTx.wait(1);
    log("Box ownership has been transferred to TimeLock contract");

}

1 Answer 1

2

Try using contract.target or await contract.getAddress() instead. Ethers v6 has different interfaces to Ethers v5.

https://docs.ethers.org/v6/api/contract/#BaseContract-target

It's possible you have differing versions installed. Frameworks and tool sets have not settled on a commonly supported version.

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.