Ethereum is a public blockchain that supports distributed computing and provides smart contract capabilities on its EVM (Ethereum Virtual Machine). Smart contracts will transform several major industries in the coming years. At first glance, the concept of a smart contract seems simple and basic. However, the range and versatility of operations smart contracts offer is incredible.
I recently attended the Certified Ethereum Developer (CED) program at York University’s Blockchain Hub in Toronto. This certification program is the first of its kind. It focuses on Solidity, a programming language that runs on the Ethereum blockchain. By the end of the three-day intensive program, the other attendees and I, were able to code our own smart contracts and create tokens. The course also covered topics including ICOs, DAOs, smart property, and other emerging blockchain concepts. The program ends with an exam and a Capstone Project.
I teamed up with Ben Brown and Mo Hasan to build smart contracts focused on smart city and government services. Our Capstone Project was a hypothetical municipality that ran its tax collection and municipal services through a series of smart contracts. Even though we completed and submitted the project, we continue to tweak it and add more features.
Though I have been in the blockchain space for years, it was exciting to learn and revisit several new topics during CED. Some of these are below:
Ethereum is modular and very flexible. A user can tweak the protocol and change several components of it to suit specific organizational needs. Two important such components are:
1. Difficulty level — how difficult do you want to make mining on your network? How much hashing power will it take to solve a block?
2. Consensus mechanism — which consensus mechanism do you want your protocol to follow — proof of work, proof of stake, or proof of authority?
Building a blockchain
We worked with GETH and created an internal blockchain for CED attendees. The experience of creating a blockchain from scratch, maintaining it, and participating in transactions on it, was immensely rewarding. It allowed attendees to put their conceptual knowledge into practice. It helped crystallize the following concepts, among others:
1. Genesis block — in the process of creating our genesis block, we assigned values to several variables, including the volume of currency allowed in this particular blockchain, and how much each user was assigned.
2. Timestamp — each block is timestamped with the time at which it was created. Interestingly, Ethereum follows Unix time, which means that it considers the beginning of time to be 00:00:00 UTC Thursday, 1, January 1970 (also known as POSIX time or epoch time).
3. Mining — we used the commands ‘> mining.start’ or ‘> mining.stop’ to start or end mining sessions on our cryptocurrency.
4. Transacting — we then used the coins we had mined to transact with one another within our network, and also paid fees in the form of ‘gas’ to enter data into each block.
5. Communicating — along with sending cryptocurrencies, we were also able to send messages in ‘string’ form as part of the transaction data. Messages can be sent to inform another peer of various attributes, such as your Status, your current Ethereum State, and node data.
Smart contracts are agreements that are written in code and that are self-executing. They permit transactions to be conducted in a distributed, safe, and transparent environment. (The smart contract concept was first proposed by Nick Szabo in 1994 — this may be why ‘szabo’ is a denomination of ether: 1,000,000 szabo = 1 ether.) Some important smart contract concepts include:
1. Gas — this powers each smart contract. Ether can be converted into gas. The gas exists on the Ethereum Virtual Machine. It cannot be traded on other exchanges. The price of gas is not pegged to ETH. Rather, it varies according to a complex algorithm. Executing a transaction or smart contract uses gas. The amount of gas required is proportional to the complexity of the contract.
2. Contracts can call on other contracts — they can call functions of other contracts, and can be programmed to create and deploy other contracts using ether and gas.
3. Inheritance — a contract can be programmed to inherit code from one or more other contracts.
4. Calling a contract — creating and putting a contract on a block is a necessary but separate step from triggering that contract by calling it. The entity calling a contract is known as ‘msg.sender’, while the entity at the beginning of a call chain is called ‘tx.origin’. For example, in call chain A > B > C >D > E, ‘msg.sender’ could be E while ‘tx.origin’ is A. (n this scenario, A called on smart contract B; B (according to what the contract demanded) called on C, and so on. The immediately previous actor is denoted by ‘msg.sender’ while the original entity at the very beginning of this chain is called ‘tx.origin’.
The instructors who taught this course were experts in their fields and had a broad range of experience in blockchain technology, distributed ledger applications, payment systems, cryptography and entrepreneurship. I found my colleague Aalim Khan to be a gifted programmer who is highly skilled in Solidity and creating smart contracts.
While this post highlights some of my thoughts, it only scratches the surface of what the program covers. For brevity’s sake, I omitted several important conceptual (such as creating our own ERC20 tokens) and social (such as making friends among attendees, instructors, and others in the blockchain community) aspects of the program. While coding skills are a definite plus, a basic understanding of programming is enough to learn a ton from this course.