I am using "hardhat-deploy" npm package to deploy the smart contracts.

Inside the deploy script, I am trying to call a function like so:

**await trueYield.connect(player).stakeEther(30, data)**

The contract deploys fine but then it gives error:

TypeError: staking.connect is not a function

How can I connect to a different account than "deployer" and call a function on the contract?

  • 1
    contract.connect(player) is the correct way, but the error msg looks like is not raised by the code you showed, could you show more code detail? Sep 17, 2022 at 14:37

1 Answer 1


You can try adding this line of code after your contract is deployed:

const contract = await ethers.getContract("ContractName")

now when you use contract.connect() it should work

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.