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 Answer 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. Commented Sep 6, 2018 at 16:31
  • Do you want to use a public or private blockchain?
    – Vasay
    Commented Sep 6, 2018 at 16:54
  • I think that a private or consortium blockchain will be a more efficient choice. Commented Sep 6, 2018 at 16:57
  • Any suggestion? Commented Sep 8, 2018 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
    Commented Sep 8, 2018 at 20:39

Your Answer

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

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