Tag Archives: blockchain

Smart Contracts using blockchain

One of the emerging trends in computing that everyone talks about, but can seldom articulate, is blockchain. What is that, you ask? If you’re like me, and haven’t done a deep dive, you’ve likely heard of it because of bitcoin, a cryptocurrency (digital money). I found a graphic that provides a nice high level description:

High level blockchain explaination

Where do people use blockchain? Anywhere you need to establish a trust relationship between applications to complete a transaction.

Now that we have a (fragile) foundation, we can dive into the GHC workshop I attended on Ethereum: A blockchain protocol with a complete built-in programming language. The workshop was presented by Julia Chou and Jenny Lu of Coinbase. Over the course of the workshop, we created a simple smart contract as a decentralized app (Dapp).

Prior to walking through the Dapp creation, Julia provided some context for the emergence of smart contracts and the use cases for blockchain.

Web 3.0: a peer to peer (decentralized) web, without servers or authorities to manage the flow of information, instead of the traditional client:server model, every client is also a server. This architecture avoids a single point of failure. In Web 3.0, browsers and wallets are able to represent identity and assets, allowing authentication and payment without using a bank or identity service. While this cuts out intermediaries for transfer of property, it leaves a gap in the establishment of trust (we trust lawyers and banks, we don’t trust unknown users with whom we’ve never interacted) — which is where the technologies we’ve discussed come into play: all processing is done via smart contracts using blockchain as the data storage and protocol.

Web 2.0 vs Web 3.0

Solidity was the language used in the workshop for developing the Ethereum smart contract. It is influenced by Javascript and C++. It is statically typed, compiled into Ethereum virtual machine bytecode, and is Object-Oriented. Ethereum is Turing complete, so a program could run infinitely — at great expense. To avoid this there is a concept called gas, tracked by ether (the Ethereum cryptocurrency), you can set a maximum amount of gas to expend, and if you run out, the program stops executing and rolls back the transaction. That is a very condensed description of a complex concept, so if you want to read more about gas, click here.

Now we can get into the workshop…

The workshop itself was intended to be completed over the course of an hour, and was targeted at (I believe) intermediate developers. The instructions are available here:https://github.com/jp3hou/dapp-demo, if you want to try it for yourself. The presenter slides are also available in the linked GitHub repository.

To complete the workshop, I will say that if you didn’t have Linux OS CLI (Ubuntu specifically), GitHub, and programming experience, you would have struggled to complete the exercise, there were a lot of assumptions. Before you start, you will need an Ubuntu OS or Windows 10 + WSL and Ubuntu, Chrome or other Metamask supported browser, and your IDE of choice; alternatively, you can use the online Solidity IDE .

The application we deployed was a simplification of the popular CryptoKitties. The core components:

And the underlying technology we used to create the Dapp:

I won’t take the time to walk through each step from the workshop, but would encourage you to follow the instructions from the GitHub Demo. Once you’ve completed the various steps to generate the test accounts, set up Metamask, and launch the Dapp, you can click on a kat to purchase it!

Successful kat purchase!

Security Concerns:

Hopefully you know a little more now than you did before. I certainly came away with my curiosity piqued!

Resources: