-
So this is not unique to Lesson 7 but I wonder why do we use .provider when reading contract but it's not needed when writing to it from JavaScript. For example: When we want to read balance we use I find this odd visually and also makes me question why is it needed for read actions and not for write? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
First question: When we use Second question: For Hope this answers your doubts |
Beta Was this translation helpful? Give feedback.
First question: When we use
.provider
we are using the set of methods given to us by Ethers: for more info click hereSecond question: For
await fundMe.withdraw()
we do not need to use Ethers. Why? Because you probably got an instance of the FundMe contract in fundMe via Ethers/deploying it, so, we can directly use the functions inside the FundMe contract (as fundMe has an instance of it) by the dot notation. So, simply,withdraw()
here is from our main FundMe contract, whereas thegetBalance()
is derived from Ethers.Hope this answers your doubts