Ethers js with REACT #3262
-
I love how Patrick Collins teaches its REALLY amazing I definitely had so much knowledge by watching his lessons. However I do have one question, is it possible to interact with a deployed contract using Ethers js in React? If so, why bother to use Moralis or APIs of such? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It is completely possible, but you'd have to write manually stuff that Moralis does easily. An analogy would be using vanilla JavaScript's Imperative Dom methods instead of React's declarative Dom methods. You CAN do similar things with both, but one is more convenient |
Beta Was this translation helpful? Give feedback.
-
Incorrect explanation.
You can, but the thing is that firstly, you will have to do everything manually. Secondly, and the main reason is that the course intended to use Moralis to show the use-case with a decentralized project (Moralis). Even if you managed to write code manually, it ultimately will be a centralized data-base unless you create a decentralized one (where nodes keep track of data similar to, say, IPFS). For convenience in minor projects, sure, you can do it; however, the course, ultimately, follows the core philosophies of Web3 (i.e. decentralization)--it serves well for practice, as well as philosophically. If a Web3 course followed a centralized approach, that would be contradictory. |
Beta Was this translation helpful? Give feedback.
-
@winterjihwan As a simple way to interact with the deployed contract, we say in lesson 8 using ethers by creating an But here (lesson 15), we went further to listen for events that smart contracts will emit and we can use a couple of storage things, like arrays, objects, etc. but storing events inside these will become temporary storage. So we need something which can remember the emitted events data. Now come to the point where we can use Firebase, AWS or anything else then why are we using Moralis that is itself centralized? Yes, we can use other options as well but as we know moralis also provides the same services also it makes the dapps creation experience amazing by providing useful methods and other functionalities (it itself inspired by firebase, but for dApps). Now comes to the point of centralization, yes we know it is centralized but it does not ruin the web3 decentralization property, because it will contain only the emitted data and cannot control the smart contract anyway, our contract will be totally decentralized. But curious developers also created a solution for it as well, where the emitted data will also be decentralized and there comes the graph protocol. Hope now the flow is clear. |
Beta Was this translation helpful? Give feedback.
It is completely possible, but you'd have to write manually stuff that Moralis does easily.
An analogy would be using vanilla JavaScript's Imperative Dom methods instead of React's declarative Dom methods.
You CAN do similar things with both, but one is more convenient