I am finding it difficult to understand difference between these two.
2 Answers
getSigners
and getNamedAccounts
are both used for the same purpose, getting public key for accounts.
Since you asked for getNamedAccounts
I assume you are developing on a hardhat environment because it is used to retrieve accounts manually from the attribute namedAccounts
defined whithin hardhat.config.js
and it is an exclusive feature with the plugin hardhat-deploy
.
In the other hand a signer in ethers.js is an object that represents an Ethereum account. getSigners
helps getting a list of the accounts in the node we're connected to, which is probably the Hardhat Network.
-
-
1
getNamedAccounts
configurations should be included inhardhat.config.js
, u should have a similar code snippet.json module.exports = { ... namedAccounts: { deployer: { default: 0, }, }, ... }
– jutsuAug 15, 2022 at 22:19
If I write getNamedAccounts instead of getSigners in my code, the code won't run ?
Because you are using named accounts. That's why getNamedaccounts
results in an error.
Check your hardhat.config
, looking from gist you may have a Named account variable as deployer.
-
-
javascript namedAccounts: { deployer: { default: 0, }, user: { default: 0, }, },
– amitAug 16, 2022 at 3:27