getSigners() #2579
-
i dont understand getSigners() method return accounts array like [owner,acc1,acc2,acc3]=getSigners() from where these accounts come i mean these accounts are which one? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
Hey @Naveed-Jameel just like ganache, hardhat comes with a list of accounts for your local development needs. Hardhat gives you 10 accounts/signers that you can work with. If you remember correctly, we normally add an |
Beta Was this translation helpful? Give feedback.
-
@Naveed-Jameel These just are two different methods of ethers that return the contract, just the difference is that |
Beta Was this translation helpful? Give feedback.
Hey @Naveed-Jameel just like ganache, hardhat comes with a list of accounts for your local development needs. Hardhat gives you 10 accounts/signers that you can work with. If you remember correctly, we normally add an
accounts
section under networks in our hardhat.config.js file. In this section, we can add as many accounts for eithers rinkeby, polygon, goerli, mainnet, or whatever chain we want to. However, for hardhat, we don't need to because hardhat adds these accounts for us in the background and we usegetSigners()
method to retrieve them. If you want to see these accounts, just runyarn hardhat node
ornpx hardhat node
and you'll see them along with their private keys.