0

I want to deploy a smart contract on server and interact with it using mobile client. I'm not familiar with how does that work but after some research, I found something like below: enter image description here

If we compare communication through web services in mobile client, then pretty much everything is same expect in Smart contract, is no database or deployment service as the result of decentralized nature of the system. Is that right? We can connect mobile client to smart contract using some library like web3 which would essentially work with Json RPC or websockets.

But what if I don't want to connect each mobile client to smart contract using library like web3? Instead, what if I want to have a HTTP server and then it would connect to smart contract like below? enter image description here

Is that possible? If yes, then how can I do that?

My second question is regarding deployment. In the centralized server scenario, I would have database deployed on some service like AWS etc. I could estimate the deployment cost. I understood that we have to deploy smart contract on Ethereum mainnet which will cost some x amount of Ether. But then I found out that my users will have to pay for each computation. What if I want to bear all the costs? How can we estimate such costs?

Please guide me on the above questions.Thanks.

1 Answer 1

0

1) Why don't you just write web3 code, eg using web3js, in your server? You would need to be running an ethereum node on your server too. That way your HTTP server acts as a gateway to the mainnet for all of your clients. Or do you not want to do that?

2) You can estimate the cost of a transaction in web3js using https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#contract-estimategas.

8
  • 1 - Ok. Then if I want to connect mobile client, do I need to connect wallet and pass an address to the server? Jan 7, 2019 at 13:19
  • 2 - But what If I don't want user to pay for each transaction and bear the costs myself? Jan 7, 2019 at 13:20
  • 1
    1) The server would have a single ethereum address which it uses to pass data on from the mobile clients. If you want each client to have its own ethereum address, that is more complicated. Jan 7, 2019 at 13:38
  • 2) Your server would be the only entity sending transactions to the mainnet - you would automatically be paying the gas, not your clients. Jan 7, 2019 at 13:39
  • Ok...one last question : I want each client to have own ethereum address but that should be generated on server. Is that possible? Jan 7, 2019 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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