
Course overview: an introduction of the entire course curriculum. From fundamental concepts of Blockchain technology, Ethereum, Smart Contract, Solidity to Coding sections on ERC standards.
Blockchain is a time stamped, append only transaction log.
Blockchain is:
Globally open – accessible on the Internet by anyone,
Distributed – thousands of computer nodes running it and maintaining it,
Secured by Cryptography technology - that any tampering can be easily detected, and uses digital signature to authenticate and verify transactions
Decentralized – a Peer-to-peer network with no Single point of failure.
Auditable – every transaction can be verified ( sender, recipient, value, time-stamp,
In short - it is a Distributed Ledger System that record values
Blockchain - is the Internet of Values. A Trust Machine!!
Bitcoin - is the world first decentralized peer-to-peer digital currency. Before the invention of Bitcoin there were many attempts to introduce electronic cash system but failed.
Bitcoin - a successful innovation by Satoshi Nakamoto had demonstrated that we can have secured digital currency on the Internet and make or receive payment directly with anyone on the system without the need of intermediaries such as banks or institutions.
This is a revolutionary and transformative technology. The crypto currency Bitcoin, is protected by cryptographic technology, 'proof of work' consensus protocol and decentralized network architecture.
Ethereum is a global decentralized super computer. To understand this statement is to know how Ethereum extend beyond Bitcoin blockchain decentralized payment system.
In this lecture you will see the motivation and contrast of Ethereum with Bitcoin.
You will learn about EVM (Ethereum Virtual Machine) and the idea of Smart Contract, various Client software and Gas price in Ethereum eco-system.
Remix - an IDE for Solidity Smart Contract coding, compilation, deployment and testing environment. This is a browser based tool that do not need any installation.
This is an important development tool for Smart Contract. You can access this tool from the website.
http://remix.ethereum.org/
In this tutorial, we will learn another DevToolL Ganache. Ganache is a local Blockchain that you can install on your PC and use Remix to deploy and test your Smart Contracts. We will also learn about MetaMask - a very popular browser-based e-Wallet for the interaction with Ethereum blockchain.
You can install and find out more about MetaMastk here:
https://metamask.io/
And Ganache :
https://www.npmjs.com/package/ganache-cli
In this session of learning Dev Tools, we are going to learn from an example of a Smart Contract - Ownership contract. The Ownership contract is important as it is one way we can control the contract the we deployed on the blockchain. Ownership can be transferred as needed and certain functions in a Smart Contract can only be assessed by the contract owner.
In this session we are going to learn the Web3 JavaScript library that allow us to interact with our Smart Contracts from Nodejs environment.
You will see how by just installing Web3 and using the object functions of Web3 we can get information directly from the production Ethereum network.
You can find out more via this link:
https://www.npmjs.com/package/web3
In this session we are going to learn Truffle - a Smart Contract development framework that is quite popular with many developers.
Unlike Remix which is a visual oriented browser based IDE, Truffle is mainly a command line based tool which provide a boilerplate structure for your contracts, compilation, deployment and testing functions.
The strength of Truffle is that it helps developers to streamline their development works and conduct testing specification. I like the testing feature as you can re-run your past tests whenever you have a change of your code.
So, do learn this tool well and use it together with Remix which are easy and visual for each simulation and front-end testing.
You can find information here:
https://trufflesuite.com/index.html
In this session, we formally define and go into the development of Smart Contract.
A "smart contract" is simply a program that runs on the Ethereum blockchain.
It's a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.
In this session we are going to write a Smart Contract for a Vending Machine! Yes, although it is virtual vending machine, the functionality and logic are the focus of the Smart Contract. Enjoy!
Solidity - Data Types and Usage Examples.
Note: the contract source codes in the demo exercises are provided in the Resource zip file here. ( for all the Solidity examples ) Use it for your convenience.
Solidity - Data Types and Usage Examples
Solidity: Functions, Visibility, Scope and Modifiers
Solidity: Functions, Events, Payment and Control
Solidity - Inheritance, Payment, Event, and Access Control
Solidity: Abstract Contracts, Inheritance and Interface
As shown in the demo tutorials, Smart Contract can be developed using Remix , compile, deploy and test within Remix.
However, we can also use web3 in the NodeJs environment to connect to Ethereum and interact with our deployed contracts.
This is a power example and ease of use of Nodejs and web3.
Please unzip the Resource files for your convenience.
Later exercise we use React as front-end rather than NodeJS. MetaMask thus become available as it is browser based extension.
For the ERC20 practical tutorials, please ensure you have install the following according to the instruction in the demo videos:
React: npx create-react-app <folder_name_lowercase>
web3: npm install web3
axios: npm install axios (note: you may not need this)
openzeppelin: (please follow videos in the later video when we use this library)
Solidity contract development can be done on Remix
Note: if you encounter installation or runtime error, this is a great opportunity to debug and find out solutions yourself.
The files in the Resource folder here is for your convenient.
You need to know where these files should replace what files in your own PC directories.
Please bear in mind that to interact with Smart Contract on Ganache or Testnets of Ethereum, you need 2 things:
The ABI file. (you can get from Remix once you compile your contract)
The deployed Address on Blockchain of your contract.
Since this two information will be different from the resource file examples, you can expect errors if you did not change them accordingly.
Please use the resource files with understanding.
For the NFT practical tutorials, please ensure you have install the following according to the instruction in the demo videos:
React: npx create-react-app <folder_name_lowercase>
web3: npm install web3
axios: npm install axios
openzeppelin: (please follow videos in the later video when we use this library)
creating account on IPFS: follow instruction in the last video on creating an account on Pinata | Your Home for NFT Mediahttps://www.pinata.cloud
Solidity contract development can be done on Remix
Note: if you encounter installation or runtime error, this is a great opportunity to debug and find out solutions yourself.
The files in the Resource folder here is for your convenient.
You need to know where these files should replace what files in your own PC directories.
Please bear in mind that to interact with Smart Contract on Ganache or Testnets of Ethereum, you need 2 things:
The ABI file. (you can get from Remix once you compile your contract)
The deployed Address on Blockchain of your contract.
Since this two information will be different from the resource file examples, you can expect errors if you did not change them accordingly.
Please use the resource files with understanding.
This practical session demonstrate how to use OpenZeppelin library and wizzard to generate the required Smart Contract.
https://wizard.openzeppelin.com/
The contract once generated, was tested on Truffle using the MyERC1155_Test.js statements. As an exercise, you can code more test statements in the file and run it using: truffle test
Note: remember to set up truffle by creating an empty directory, and in that directory, do truffle init (as shown in the demo). The do the truffle compile
and truffle migrate and eventually truffle test.
Preventative Techniques:
Use the pattern: Validate-Effect-Interact
Ensure all state changes happen before calling external contracts
Use function modifiers that prevent re-entrancy on any withdrawal functions
Here is a example of a re-entracy guard
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;
contract ReEntrancyGuard {
bool internal locked;
modifier noReentrant() {
require(!locked, "No re-entrancy");
locked = true;
_;
locked = false;
}
}
// you can try on Remix to solve the problem explained earlier tutorial.
Escrow management demonstrate one safe way of handling Ether on Smart Contract is by 'pulling' approach rather than 'pushing' approach. Pulling approach is to use an Escrow contract to hold Ether due to the rightful user.
The user can then activate the withdrawal from the Escrow contract. This separation of Ether and contract logic of the Escrow contract is demonstrated in this session. You can find the resource on the Escrow contract below.
Testing of Escrow service management contract.
Note: the files used in the demo are in the resource below. You have to copy the respective files to the right folder of Truffle.
Final summary session of the course. Thank you for working hard and reaching the last learning session.
We recap what we learned about Ethereum Blockchain technology, Smart Contracts, Solidity, Web3, Standards and Security Issues of Smart Contract.
A note about the limitation of current Blockchain technology and you need to evaluate the problem first to see if Blockchain is the best solution or using conventional full-stack client server is better.
You are encouraged to learn further by doing a real dApps project.
One website you can find and discover ideas for dApps is this:
https://dappradar.com/
Wishing you all the best for your future learning journey and success for your career.
Thank you.
Sincerely,
Abel Choy
This course is designed for anyone new to Blockchain technology and Solidity programming. You will learn and use Solidity to write Smart Contract and deploy it on Ethereum as a Decentralized application - dApps.
DApp is a new trend of writing programs which is able to enforce the contract based on rules, logic and events; and execute automatically by transferring Ether payment based on those conditions.
DApp do not require intermediaries like banks or institutions as it is able to validate, authorize and settle transactions and record them on the immutable Blockchain. It's essentially a 'Trust Machine' where transaction is open, verifiable and permanent on the blockchain.
Blockchain is the most promising technology of the future since the invention of the Internet.
What you will learn in this course:
Ethereum Blockchain Technology
Solidity Programming Language
Development Tools for dApps
Write Smart Contracts for ERC20, ERC721, ERC1155, and Escrow Services
Smart Contract Security Issues and Solutions
Write front-end Web3 application to interact with Smart Contracts and IPFS
The Blockchain technology that we are learning in this course was actually inspired by the innovative and successful implementation of Bitcoin system.
Bitcoin was invented by Satoshi Nakamoto in his / her paper titled "Bitcoin: A Peer-to-Peer Electronic Cash System“. ( 2009 ) Bitcoin is both a digital currency and direct peer-to-peer payment system. (i.e. no banks or governments involved in the transfer)
Interestingly, the word 'Blockchain' was not mentioned in the white paper. It was later discovered by developers and communities that this Bitcoin is running on a new technology (we call it Blockchain) which solved the 'Double Spending' problem where many earlier electronic cash proposal failed.
The Bitcoin Blockchain proposed and implemented by Nakamoto essentially fuse together the following technologies which were known at that time:
Cryptographic hash function,
Proof-of-work consensus protocol,
Decentralized Network Architecture
The ideas and innovation was quite ingenious. Together with the participation of the Miners in the system, every block is inspected and validated and Miners compete to have the right to add the new Block by solving a cryptographic puzzle first.
The Miners who first solved the puzzle will broadcast to the Peers and a 'Proof-of-Work" is demonstrated and verified by other Miners. The Miner who solved the puzzle got the right to add the new Block, receive Ether reward, and the process continue on.
So, every attempt by a malicious attacker to the Bitcoin network (ie. essentially attempting to re-write the transaction log) will need to compete with the entire network of Validators. It has been shown that it is very difficult to cheat or bring down the Bitcoin network.
With the success of this innovative Blockchain technology, the developers and corporations started to evaluate whether we can use Blockchain to decentralized other assets beside money.
Assets such as property title, certification, voting system, supply-chain system, artworks, health records, etc., becomes feasible as each of the asset requires recording system (i.e. a public Distributed Ledger System)
The idea of a trusted DLS where transactions are verified by the peer nodes continuously through cryptographic hash keys protection, and decentralized network architecture with no single point of failure - is an attractive proposition for new decentralized applications (dApps).
However, the Bitcoin blockchain has inherent limitation to be used for other more complex application as was discovered by Vitalik Buterin. Bitcoin system is not a 'Turing Complete' machine. (ie. you can write simple scripts on Bitcoin blockchain but it is limited to transfer of Bitcoin and not able to implement more complex applications )
In 2013/2014, Vitalik proposed and implemented Ethereum - a decentralized, open-source blockchain system with Smart Contract functionality.
The proposal is to build an EVM (Ethereum Virtual Machine) - a Turing Complete machine - that will run on each Node / Client computer on the network. And Smart Contracts are just programs written in Solidity - a programming language that target the EVM for deployment and execution.
With Ethereum blockchain system, developer can design Smart Contract, compile it, and deploy on the Ethereum network. This is quite an amazing innovation. The Ethereum blockchain thus become a Global, Open, Super Computer -where Smart Contract programs can be deployed and executed for various kind of decentralized applications.
We will be learning Solidity programming language for Smart Contracts development and examine the language, examples and application in detail during the course.
In short, Ethereum is a programmable Blockchain. A platform for running Smart Contracts (beside the ability to send / receive the native crypto currency Ether)
We will learn a range of Development Tools for writing Smart Contracts, compilation, deployment and testing in the course.
In a series of practical sessions, we will look at ERC20, ERC721 and ERC1155 as examples of industrial standard contracts and write our own tokens using those standards.
As Ethereum blockchain has a native crytocurrency (ETH Ether), the transfer and exchange of money is integrated with the Solidity programming code. Hence, it is possible to automate agreements and execute them based on verified events and rules of the contract to send monry (i.e. Ether) directly to each other - thereby eliminating the intermediaries (ie. Banks, Insurance company, (i.e. noteL a Smart Contract can hold Ether values as well beside EOA (Externally Owned Account) by users.
The possibilities and use cases of Smart Contracts are just endless and we are limited only my our imagination.
With the possibility of financial transactions that can be executed automatically by Smart Contracts - it opens up the risks of malicious Hackers to exploit errors or bugs in a Smart Contract. History had shown incidents of cybercrime where millions were stolen from Smart Contracts / Account Holders.
Therefore, every Smart Contract developer must have a good grounding on Smart Contract Security and know how to write code to protect the Owner and Contract itself. We will look at the classic attack of Smart Contract in the last session and how to overcome it.
Benefits to you for learning this course:
Gain knowledge and skills of Blockchain technology and dApps development
Prepare yourself for many high-demand job opportunities in Blockchain technology
Kick-start your opportunities to launch Start-up projects using Blockchain and dApps
What's the difference of this course with other courses on Blockchain:
This course is designed with total beginner in mind and simplify complex topics
We first cover the fundamental concepts of Blockchain and related topics before diving into coding
We avoid confusion and courses which use outdated tools
Learn by coding is the key to go in depth into the technology
Come, join us today!
Yours faithfully,
Abel Choy, Software Engineer / Lecture in Computer Science