1

How can a smart contract receive data (strings or int) from an html page? I would like to receive some information that a user con insert in a web page, in order to save them in the blockchain (for example the height and length of an object, together with the timestamp of that action).

Is there any function or something that allows to import those informations?

Thank you.

1

You can use the library web3.js (on the client side in conjunction with MetaMask). Or the libraries Web3.js, Web3.j, Web3.py on the server side.

The main question - who will pay for the transaction - you or the customer?

Also, in the second case, to send a transaction from your page, the client should have MetaMask installed

  • I was thinking about a real use of a smart contract in a company, where an employee can insert some information through a web page, and that those informations will be saved in the blockchain. So, the company will pay for the transaction, but I don't know how the smart contract can receive the data from the html. – Davide Bettinelli Sep 6 '18 at 16:31
  • Do you want to use a public or private blockchain? – Vasay Sep 6 '18 at 16:54
  • I think that a private or consortium blockchain will be a more efficient choice. – Davide Bettinelli Sep 6 '18 at 16:57
  • Any suggestion? – Davide Bettinelli Sep 8 '18 at 9:17
  • Perhaps for a private blockchain you should look at Hyperledger Fabric. But, if you are interested in Ethereum, and you want to deploy its local version, you need to decide how you will sign the transactions on the client computers. To make MetaMask work with local blocking is not difficult. Then to send the transaction from the local site, use web3.JS. – Vasay Sep 8 '18 at 20:39

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.