5

I have a contract with a bunch of functions that don't involve ethers or any kind of funds at all. Basically all I want is to have a html page with forms that allow people to use those functions.

All transactions would be done from the same ethereum address, using ether only as gas. Users would need an account to avoid anyone draining all my gas, account that I only give to certified people, and with a limited number of transaction per day or per hour.

Basically, users don't even have to know they're using a blockchain.

Currently my contract is running fine on Ethereum Wallet, what would I need to deploy an app ? Tutorials I find seem overcomplicated.

What is the most simple way to call contract functions from a web page ?

3 Answers 3

2

I've already thought about this kind of scenario where the blockchain's complexity and security is completely hidden from the end-user. It could happen if you want to use the blockchain more as a immutable database than a ledger.

My solution consists in developing a NodeJS API :

  • GET /api/resource
  • POST /api/resource
  • PUT /api/resource
  • DELETE /api/resource

For the GET method (read), it's not really necessary because you can directly inject web3 and connect it to a node. So you will be able to read data in the blockchain via your "constant" contracts functions or "public" attributes.

For the POST/PUT/DELETE (write), every transaction must be signed. So your frontend/clientside code could call the API (backend) which will execute a transaction using for example Ethereumjs-tx. In that way, every transactions will be signed by the same address owned by the API.

But as you said, if someone replays many times the HTTP request, it will drain your account with gas. So your API should have at least the following functions:

  • Authentication

  • Rate limit

I haven't implemented this solution, it's just something I draw a few weeks ago. So I might miss something.

0

If I understand correctly and your users have their own addresses, then you have two options:

  1. Have them use the Metamask plugin in chrome

  2. Have them use the Mist Browser

Without one of these, your user's will not be able to interact with the smart contract.

Furthermore, taking a framework like Meteor or Truffle helps you to design simple DApps fairly easily using the web3.js lib.

The simplest way to interact with your SC would still be to watch it using the Ethereum Wallet. You only need the address and the contract's ABI for that. You will get a standardized GUI to interact with any contract.

2
  • Actually no, they don't have their own addresses. It's not very clear, but as I said, there is only one Ethereum address. Users have an account that is not related to Ethereum, like you'd have an account on any site. I basically want to make the Ethereum layer invisible for the user. Nov 2, 2016 at 16:34
  • Is there a way to have automated transactions, so I don't have to write my password every time ? Nov 2, 2016 at 16:36
0

If you're going to have accounts that you manage yourself, I imagine you'll be running some kind of server-side software (PHP, Ruby on Rails or whatever).

So run a Geth node on your application server, listening only on localhost, and use a library for whatever server-side software you're using to talk to it via JSON-RPC.

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.