0

I am new to the solidity/dapp game, but I'm learning.

Here is some super simple code for a smart contract that I'd like to use to store user input strings from a webform and store those responses on the blockchain so they can be queried later:

pragma solidity ^0.4.0;

contract simpleStorage {
string name;
string email;

function simpleStorage() public {
   name = "Hello";
   email = "hi@gmail.com";
}

function setInfo(string userName, string userEmail) public {
    name = userName;
    email = userEmail;
}

function getInfo() constant returns (string, string){
    return (name, email);
}
}

Right now I'm trying to figure out how to a) accept string user input, convert to JS/JSON readable format with double quotes and b) set up the web form to work with this contract and my private geth network

  • what is your question? have to be more specific – jojeyh Oct 5 '17 at 20:31
  • How do I go about accepting user entry and feeding it into this smart contract? – Forrest Oct 5 '17 at 20:57
  • I also don't know how exactly the connectors to a webform work – Forrest Oct 5 '17 at 21:01
1

Building a webform is out-of-scope for this community, just too many frameworks to choose from. But for the contract integration, I'd recommend you use the Web3 JavaScript API to interact with the Ethereum network, which seems to be the most popular at the moment.

Another really great client library is Ethers.js, with amazing documentation found here.

Once you figure it out, interacting with your contracts becomes trivial.


It's worth mentioning that when implemented on the client-side (that is in the web browser), the burden is then on the user to execute these contracts using their Dapp browser (Mist or MetaMask). If you want this all to run behind the scenes (without the user having to know anything about Ethereum or blockchain), then each of the aforementioned libraries also have their Node.js counterparts, which can then be tied to your server's own ethereum wallet.

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.