5

I want to have an html/Javascript code interact with a smart contract. Can someone please outline the basic/high level steps? I am seeing too many things spread across the net, finally confusing.

5

This might be of some help. http://hypernephelist.com/2016/06/21/a-simple-smart-contract-ui-web3.html

There are frameworks that conveniently deal with dependencies, so a lot of us prefer to go that route. A very high-level overview if what's described in the link, is you will need to:

  1. load the web3 API
  2. get the ABI (a JSON helper that describes the interface to the contract)
  3. initialize an instance of the contract at the address where the contract resides using web3.
  4. call() (read-only, fast and gas-free, returns value) or sendTransaction() (state-changing, needs mining, costs gas, returns txnHash).
  5. you get a callback from step 4. Wait for the transaction to be mined and then get the mined transaction to see the values, if it was a state-changing transaction.

I hope I didn't miss a step. It's high-level. The link above seems to cover the steps described. :-)

Hope it helps.

1

Have a look at the JavaScript Web3 API. It has almost everything you need such as connection to your blockchain, creating and deploying a smart contract, interacting with them.

In my opinion, no need to describe an example, the doc speaks by itself.

1

Give a try to Embark, the embark demo route is a very good way to quickly get started.

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.