I am trying to build a dapp but I am having problems. My idea is: I have a front-end written in html / css and a backend implemented with web3.js thanks to which it is possible to connect to a blockchain node. is this reasoning correct? Now how does a user connect to my dapp? Should you use a wallet?
-
it depends on what and where you are implementing it. take look at metamask and some other dapps tutoirals :) probably you should edit the question, add more information, and specify your problem or question before it get closed– Majd TLFeb 23, 2021 at 12:55
-
There are several technologies to allow users to connect to a dapp: Metamask, WalletConnect, WalletLink, Fortmatic, etc.– Ismael ♦Feb 25, 2021 at 4:40
2 Answers
You probably need to define your requirements and explain why you need a backend. If you manage all web3 interactions from the backend, you will also have to manage wallets / private keys, assume transactions costs... and not sure this is what you want.
From my perspective:
Frontend: You can use web3 (web3.js or ethers.js) to connect to a browser plugin such as Metamask to allow users sign transactions without sharing their keys, which is the simplest and more secure way (and the users will pay for their transactions, not you).
Backend: If you need to store user data off-chain, or track the status of the ongoing transactions to restore the website page with the current transactions if the users leave the page, or do calculations such as yield interests, etc then you probably need a backend. Other than that, I would keep as much web3 stuff as possible in the frontend (to make it more a DApp).
- On an ideal DApp no backend is needed, and the user uses a wallet and frontend to communicate with the blockchain directly
- On less ideal situation DApp no backend login is needed and it has only public functions
- If you still need a login use Sign in with Ethereum with your backend