Replies: 2 comments
-
@RohanNero This is a feature provided by the hardhat plugin that you can give the name to your addresses so that you can easily access them and use them throughout the deploy scripts, tests, etc. By defining this in a hardhat file, we are saying that whatever network we use, you should pick the addresses from that network and give them these names. Address at index 0 should be named as namedAccounts: {
deployer: {
default: 0,
},
player: {
default: 1,
},
}, This way, when you will run your code on a local node (hardhat), hardhat will pick the addresses (hardhat 10 accounts) and assign it to these name variables. But on testnet/main, because we only have 1 main address, hardhat will assign that main address to the The purpose of using addresses this way is to make it easy to use the addresses throughout the development journey, instead of using and remembering the long 48 bytes of addresses. |
Beta Was this translation helpful? Give feedback.
-
deployer = (await getNamedAccounts()).deployer Let's break this down piece-by-piece. Firstly, So, Ultimately, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to write some staging tests and want to know the best practice for connecting your Ethereum account to the contract you are testing on the testnet.
I see that we often just used this:
But I don't fully understand what is actually going on in this line of code, if someone could explain I would greatly appreciate that!
Beta Was this translation helpful? Give feedback.
All reactions