0

I'm building a Dapp using NodeJS and Express with ejs files. I wonder should I call web3 API in the Backend JS file or front end EJS/HTML files?

Some thoughts I have is:

  1. calling web3 api in backend is more easy to control, but the problem is when the code is executing concurrently, it is possible that some blocks has not been mined and the future function is already being called which requires the previous function to be completed first.

  2. calling web3 api in front end EJS file would be a little complicated since I need to pass the contract and account addresses and require all the ethereum modules at front end.

I'm new to Dapp development, please correct me if I'm wrong and please give me some advices or examples.

Thanks

1

It really depends on what you want to do. If you will only make calls to contracts, not transfers, you probably will want to load web3 from the back end, however, if you'll do things that require the user's private key, you should do it in front end, to avoid storing private keys in the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.