10

I am studying about DApps and Ethereum. I did get the Solidity part but I am confused about the front-end apps.

Is it possible that I use web framework like PHP Laravel/Rails for Frontend/Db operations and interact with backend Blockchain via web3.js or anything?

Jesbus
  • 10,478
  • 6
  • 35
  • 62
Volatil3
  • 337
  • 2
  • 3
  • 12

2 Answers2

9

Yes.

There are two approaches to consider

You can interact with Web3 on the client side and JavaScript

  • The user uses Mist or Parity browser or MetaMask and are connected to their own Ethereum node

  • All interaction with the user wallet (private keys) happens on the client side, in JavaScript

  • This is safe because the user does not need to give the control of his or her private keys to the service provider

  • You can still render pages in whatever backend programming language you wish, but currently web browsers do not support other scripting languages besides JavaScript

Here is a tutorial to build a frontend.

Old fashioned way

  • You can interact with Ethereum node on the server-side as you would interact on the client side

  • Web3 has standardish implementation for all programming languages (except maybe not PHP). Web3.py allows interaction from Python, you can use Web3.js in Node.

  • These libraries speak to Ethereum node running locally on the server side over JSON-RPC

  • You might need to do accounting for your users, a non-trivial task that I would not recommend non-experienced programmer to try

Also see Executing a Smart Contract in a Mobile App

Mikko Ohtamaa
  • 22,269
  • 6
  • 62
  • 127
  • 1
    Hmm it mean traditional browsers like Chrome etc can't be used for GUI? – Volatil3 Mar 16 '17 at 10:54
  • @Volatil3 chrome only with metamask plugin – Nicolas Massart Mar 16 '17 at 12:07
  • @Volatil3 Alternatively you can ask users to enter their private key and you can sign the transactions from them, like in the tutorial link I gave – Mikko Ohtamaa Mar 16 '17 at 13:03
  • @Volatil3 There was a reddit discussion on this: https://www.reddit.com/r/ethereum/comments/4stat8/creating_a_dapp_for_chrome/ You might also want to consider reading the ConsenSys tutorial to learn about serverless architecture and Dapp dev. http://consensys.github.io/developers/articles/101-noob-intro/ – Dominik Harz Mar 16 '17 at 13:30
  • @NicolasMassart ah so there is dependency anyway. Does that mean I can't have an independant browser based client talking with some ethereum library in Python or other and return responses? – Volatil3 Mar 16 '17 at 16:56
  • @Volatil3 if you really want you users to use a regular browser without a simple plugin you'll have to manage transactions for them and hence ask for their private key. No one will use your app, this is not blockchain spirit of apps you don't have to trust. – Nicolas Massart Mar 16 '17 at 17:00
  • @NicolasMassart I am thinking of a real world use case where your web application interacting with a blockchain at backend..ideally two parties should provide their wallet address for transaction(similar to email).I am unable to stand how private keyis coming in the middle. If I am sending sender and receiver addresses, all I want at backend script to interact with blockchain, make transaction and return me status which then I can pass to front-end without installing any specific plugin. – Volatil3 Mar 16 '17 at 17:54
  • @Volatil3 what you describe is a dapp. You should read some documentation about the use of private key in ethereum. You can't walk forward without this knowledge. – Nicolas Massart Mar 16 '17 at 17:58
  • @NicolasMassart OK I will but not sure it answers my question.. as per your saying, right now we would be needing a certain browser or plugin to interfact web front-end with Blockchain and there's no way other way out. – Volatil3 Mar 16 '17 at 18:06
  • @Volatil3 no, no browser natively supports ethereum and you have to make it client side to keep all the thing trust less and without third party involved in the blockchain transactions. So you have to use metamask, mist browser or whatever client will come but good old browser won't be enough. Sorry. – Nicolas Massart Mar 16 '17 at 18:10
  • ah OK. Thanks for explanation. BTW, I mean to say to encapsulate entire stuff at backend and can just pass receiver address just like this guy did here(https://www.youtube.com/watch?v=TJBHTT88I8k&t=4m18s) – Volatil3 Mar 16 '17 at 18:39
1

I suggest you to start with this kind of boilerplate. They let's you to start with latest technologies.

underdog
  • 1,190
  • 2
  • 12
  • 24