My First DApp

John Grant
2 min readJun 11, 2017

--

In my previous post I interacted with my testrpc blockchain using web3.js via the command line. The next stage was to try and develop an interface — a DApp or decentralised application. In basic terms this consists of two parts, a normal HTML front end that interacts with a blockchain backend.

There was a lot of new stuff going on here but I still picked up enough to get something going in a relatively short time.

Screenshot of my first DApp

The DApp isn’t particularly useful, or pretty, but functionality wise it covered a fair amount, including:

  • Checking an account balance
  • Querying a smart contract value
  • Calling a smart contract payable function
  • Collecting a payment from a smart contract
  • Smart contract events and how to handle them
  • HTML front end
  • Basic react functionality

The application is based on the “Withdrawal from Contracts” example from the Solidity Common Patterns documentation. It was inspired by the King of the Ether game and the rules of the contract are:

  • To play a user submits a value of X Ether paid from his address
  • If X > historicHighest:
  • user is king
  • old king can collect previous payments
  • historicHighest = X

I saved my code on Github here.

I plan to write some more posts covering the details of the application as it helps to put everything straight in my mind. The next should cover the set-up of the application and the smart contract itself.

--

--

John Grant
John Grant

Written by John Grant

Check out my personal blog where I can actually own my own content 😉: https://pitchandrolls.com/

No responses yet