2

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
  • 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? Commented Sep 17, 2022 at 14:37

1 Answer 1

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.