7

I have a list of addresses, and I would like to use them to test my contract in my hardhat ethers project. Normally I get a list of addresses like this:

[a, b, c] = await ethers.getSigners()

but what I want to do is take address 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 and make it into a signer object so I can call:

contract.connect("0x70997970C51812dc3A010C7d01b50e0d17dc79C8").method()

2 Answers 2

4

Since a signer can be a Wallet, VoidSigner or JsonRpcSigner, you can use the jsonRpcProvider.getSigner( [ addressOrIndex ] ) which returns a JsonRpcSigner.

2
2

The simplest answer is to use the deployed contract which already has a provider..

contract.provider.getSigner('0x70997970C51812dc3A010C7d01b50e0d17dc79C8')
1
  • 1
    In your above answer.Is the address account address or the contract address or something else ?? contract.provider.getSigner('0x70997970C51812dc3A010C7d01b50e0d17dc79C8') Jul 24, 2022 at 2:02

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.