Browsed by
Tag: ethereum

Weekend workshop in NYC

Weekend workshop in NYC

The blockchain academy in NYC invited me to work with them on their teaching materials for developers, IT professionals and programmers. We also decided to take the opportunity to give few condensed workshops on smart contracts and Ethereum in NYC during the weekends.

The next (and probably last) one will take place on Oct 21-22 in Rise New York, 43 W 23rd St. Chelsea.

Here’s a video we’ve created after our previous session:

For more details:

Modifiers – Go With The Flow

Modifiers – Go With The Flow

What is a modifier

Modifiers are a neat feature in Solidity that allows us to change the flow of our code execution. The modifiers (as the name suggest) can modify the code of a function.

Look at the following contract:

contract A{
    uint public number;

    modifier zeroNum(){
        number = 0;

    function plusNumber(uint _input){
        number = number + input;
In the code above, the modifier zeroNum is executed right before the rest of the function. It reset the number value back to zero. If it wasn’t for that modifier, the numbers would have just continue to add up.
Modifiers are mostly used as a gateways in our smart contracts:
contract B{

    address public owner = msg.sender;

    modifier onlyOwner(){
        assert(msg.sender == owner);

    function register()onlyOwner(){
    //Do stuff

In this example, only the owner of the smart contract can execute the rest of the function code.

Here’s another example in which the modifier that prevents anyone below the age of eight-teen to register:

contract C{

    address public owner = msg.sender;
    string public name;
    uint public age;

    modifier onlyOwner(){
        assert(msg.sender == owner);

    modifier notMinors(uint _age){

    function register(string _name, uint _age)onlyOwner() notMiner(_age){
        name = _name;
        age = _age;

The underscore.

Each modifier contains an underscore, this is where the rest of the code is inserted. The underscore can also be nested inside the modifier.
contract D{
    uint public input;
    uint public number;

    modifier onlyOwner(uint _input){
        assert(msg.sender == owner);
        input = _input + 1;
        input = _input + 2;

    function doStuff(uint _input) onlyOwner(_input){
        number = input +1; //At the time of the code execution

The difference between require and assert

Two powerful commands are assert and require. Both aren’t necessarily related to modifiers; in fact you can use these two in any function. However, they’re beneficial when trying to follow the execution flow of the code. Both will perform some logical test and will either allow the code to continue or throw the code. Throwing is the process by which the states of the EVM is reverted to the ones before the code execution. Also, currently throwing takes all of the gas associated with that transaction. In the future, the require command will refund the users of their unused gas and might even return some value.

Multiple modifiers

We can use more than one modifier in function. Modifiers will be loaded and nested according to their order.
function doStuff() modifierOne() modifierTwo() modifiersThree(){
    //TO DO

Predefined modifiers in Solidity:

public       - called by everyone
external     - Can only be called by external function (or by "this.functionName")
private      - can only be called by functions within the contract or from its derivatives 
internal     - Can only be called internally 

payable      - can accept Ethers
constant     - don't send transactions function is executed locally

Side note – The difference between require and assert

Two powerful commands are: assert and require. Both aren’t necessarily related to modifiers; in fact you can use these two in any function. However, they’re beneficial when trying to follow the execution flow of the code. Both will perform some logical test and will either allow the code to continue or throw the code. Throwing is the process by which the states of the EVM is reverted to the ones before the code execution. Also, currently throwing takes all of the gas associated with that transaction. In the future, the require command will refund the users of their unused gas and might even return some values.
For now there's no change (both throws). In the future:
require - revert but won't take all gas. It will refund the user and return a value
assert - like the old throw - revert changes and consume all gas
Ethereum developer Working environment

Ethereum developer Working environment

If you want to create smart contracts and dApps using Ethereum, you first must have a working environment. Here I’ll share with you my personal setup and why I choose to use it.

The big picture

Our working environment should contain three main components:

Local Machine

Keep it as light as possible

1.       Google Chrome (or Chromium for Linux users)

2.       MetaMask and/or Ethereum node of your choice

3.       Optional – SSH client and terminal

Digital Ocean Droplet

This is your real working environment. Where your code will run

System requirements:

·       Ubuntu 16.04 x64

·       1 CPU

·       1 GB RAM

·       1 GB SWAP

We’ll install:

·       NodeJS

·       NPM

·       truffle

·       testRpc

·       Optional – Chai

·       Optional – Meteor

C9 IDE/ SSH Terminal


Register to C9 IDE. We’ll only use it as a browser based terminal with SSH capacities.


This is how our working environment looks like:

Creating the Digital Ocean Droplet:

  1. Create your digital ocean account. Use the following link to get 10 USD voucher. Pay attention; the subscription is auto renewing. If by the end of the first month you don’t want to be charged again, you should manually change your billing settings.
  2. Once logged in press Create -> Droplets. Choose the one that has:
    1 CPU 64 bits
    1 GB RAM
    Ubuntu 16.04 X64
  1. Name your droplet and press the Create button
  2. After few minutes you should get an email with your Droplet IP address and root password.

Connecting to your Droplet using the terminal and SSH (Optional – can also be achieved using a locally installed SSH client and terminal):

  1. Create a free account at
  2. SSH into your droplet by typing ssh root@YourIPAddress
  3. When you first log into your droplet, you’ll be asked to change your root

Set your Digital Ocean Droplet:

Create SWAP file 1 GB of RAM isn’t enough.
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Add SUDO user Don’t always work as root!
adduser shlomi sudo
Change your user account
su shlomi
cd /home/sholmi
Install NodeJS and NPM This is the framework on which we’ll develop our app.
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
sudo apt-get install npm
Install Truffle and TestRPC
npm install -g truffle
npm install -g testrpc

The relation between Truffle and testRPC:

testRPC creates a mock Ethereum blockchain. It saves you a lot of time when testing your smart contract. Because you’re the owner of the blockchain, you can mine new blocks instantly. Usually, when using Ethereum, you’ll have to wait for new blocks to be mined whenever you check you smart contract and while block time is much faster in Ethereum than it’s in Bitcoin, it might still be very distracting to have a test case that contains more than 2-5 interaction with the blockchain.

Another great benefit of using testRPC is the fact that it immediately creates multiple accounts with balances so that you can test the use of your smart contract by multiple users.


When you first deploy testrpc you’ll be giving a mnemonic 12 words phrase. If you write this phrase down, you can later re-deploy your restRPC with the same accounts.

Working with truffle:

Create a working folder and initialize your truffle project
mkdir myProject
cd myProject
truffle init
Make sure testRPC runs in the background
testrc -m "tortoise fall alarm push dream proof
 broccoli size draft betray view gather"
Test your project
truffle migrate
truffle test

Tip for metamask and testRPC:

We can set metaMask to work with our own private testRPC node simply by adding it into our custom rpc list. Open metaMask and change to custom RPC. Then add
http://yourDropletIPAddress:8545  //You might need to open port 8545
And voila, Now metaMask is set to work with your own private blockchain!
Get your Bitcoin address using Ethereum smart contract

Get your Bitcoin address using Ethereum smart contract

Ethereum and Bitcoin are both using the same type of encryption, the ECC (Elliptic Curve Cryptography) over the same graph (256k1). While it’s not really recommended, the same key pair can be used both for Bitcoin and Ethereum.

A simple Solidity code can be used to get the Bitcoin address of a public key. Such a code can run locally (as a constant function) on the Ethereum Virtual Machine to save gas, or as a regular Ethereum transaction.

The code in this example requires the user to insert their public key in its uncompressed format as an input; then it produces the binary address that matches that uncompressed public key for the main Bitcoin network. The code can be easily modified to work with compressed public keys as well (just remove the yPoint and add the side of the ECC graph). The code can also be amended to give the binary address of other testnet/namecoin.


How to create a Bitcoin address

The most basic process of deriving Bitcoin address from a public key is set in the following technical documentation.

 As you can clearly see, there’s very little to it than just hashing and appending.

Recreating the process in Solidity

First, let’s generate a random keypair using Under the tab “wallet details” we can see the uncompressed public key.

The public key
xPoint = C4BB8E42F7DA5504A456C16BE533549DA4FE580279382478F3365FF7CCBF032D
yPoint = 68A73547E809F1ABFAA51D10019E8AC682D1205448042326E9E3B91841CB9FA7

Now let’s create our smart contract in Solidity:

pragma solidity ^0.4.11;

contract BitValid{
	bytes32 constant mask4 = 0xffffffff00000000000000000000000000000000000000000000000000000000;
	bytes1 constant network = 0x00;

	function getBitcoinAddress(
			bytes32 _xPoint,
			bytes32 _yPoint)
				bytes20 hashedPubKey,
				bytes4 checkSum,
				bytes1 network)
		hashedPubKey 	= getHashedPublicKey(_xPoint, _yPoint);
 		checkSum 	= getCheckSum(hashedPubKey);
 		network 	= network;

	function getHashedPublicKey(
			bytes32 _xPoint,
			bytes32 _yPoint)
				bytes20 hashedPubKey)
		var startingByte = 0x04;
 		return ripemd160(sha256(startingByte, _xPoint, _yPoint));

	function getCheckSum(
			bytes20 _hashedPubKey)
				bytes4 checkSum)
		var full = sha256((sha256(network, _hashedPubKey)));
		return bytes4(full&mask4);

The function getBitocinAddress() takes the x and y coordinate of the public key from the user, both are 32 bytes long (the uncompressed public key) and will return 3 variables, the hashed public key (bytes20), the checksum (bytes4) and the network starting byte (bytes1).

The network starting byte is currently hard codded to 0x00 (the main starting code). You can change this code to work with any other test network.

The hashed public key is obtained by hashing the public key (both x and y coordinates) with the starting byte 0x04 twice (as described in the technical documentation). Once with sha256 and then again with ripemd160. The finale result is 20 bytes long.
function getHashedPublicKey(
		bytes32 _xPoint,
		bytes32 _yPoint)
			bytes20 hashedPubKey)
	var startingByte = 0x04;
	return ripemd160(sha256(startingByte, _xPoint, _yPoint));
After we got the hashed public key, we’ll prepend the network byte to it and hash it again twice using the sha256 function. The result of 32 bytes long is used to construct the checksum, a special 4 bytes that are used to allow another user to verify that the Bitcoin address they’re sending to is indeed a valid address.
bytes32 constant mask4 = 0xffffffff00000000000000000000000000000000000000000000000000000000;

function getCheckSum(
		bytes20 _hashedPubKey)
			bytes4 checkSum)
	var full = sha256((sha256(network, _hashedPubKey)));
	return bytes4(full&mask4);
We don’t need all of the 32 bytes, only the first 4 bytes, but slicing variables is a hard thing to do in Solidity. Luckily, Solidity does allow for easy bit manipulation and masking. You’ll need to create a mask of 32 bytes to match the 32 bytes of the sha256 output. This mask should take only the first 4 bytes, as they’re the real checksum.
The full result (32 bytes) = 0x4c30ed507a508af52063560ff8f1c09e66be0587868a0b8ca21ab337440e4e8e
Mask for the first 4 bytes = 0xffffffff00000000000000000000000000000000000000000000000000000000
checksum = 0x4c30ed50

The results

At the end of the day, we have the following three components to return to the user, the network byte (currently hard coded), the hashed public key and the checksum. These are the three components that make up a Bitcoin address.

However, this isn’t the last step. In Bitcoin, a special type of encoding is used called base58. The current code doesn’t convert the result into base58 (I’ll leave it for another day), so we’ll be forced to do this step manually.

The following website provides some tools to convert our bytecode into base58. This is basically the final Bitcoin address.

At the end of the day

Using Solidity to retrieve the Bitcoin address that matches a specific public key (and therefore, a private key as well) might be useful when you’re trying to create a smart contract that maps some events between entities on both blockchains and I suspect might have some value when dealing with identities. The procedure isn’t cheap on gas but can be done locally using the EVM. It’s a shame that there’s no access to the bytecode of the transactions in Solidity since it could have made the process of finding the Bitcoin address of the message sender automated.

The blockchain developer path – Blockchain at Berkeley

The blockchain developer path – Blockchain at Berkeley

Mapping the blockchain education ecosystem

When I created my first tutorials almost two years ago, there were very few educational resources about blockchains. The ecosystem was sorely lacking in good courses, tutorials and guides to ease the learning curve for newcomers. I remember the many days I’ve spent reading raw codes and technical documentation until I was finally able to manually connect to the Bitcoin network, create keys, sign transactions, etc.

But two years is forever in the world of blockchain, now many companies, universities, and individuals are flooding the market, offering their services as educators and validators.

The thing is that this ecosystem is still kind of a wild west. There are very little standardization and collaboration between different players in this ecosystem. And the final result is sub-optimal, both for those who wish to educate themselves and for those who want to work with them (future employers/potential business partners).

But fear not, I’ve taken upon myself to try most of the major courses available and to receive as many certifications as possible. And I’ve got some interesting insights on the right route an aspiring blockchain developer should take.

I the following posts I’ll review the following courses and certification process:

  • Princeton University – Bitcoin and Cryptocurrency Technologies. Available as a full course at Coursera
  • Berkely University – BLOCKCHAIN at Berkely.
  • Stanford University – Bitcoin and Cryptocurrencies.
  • Multiple Youtube channels and videos (including my own)
  • Book – Mastering Bitcoin: Unlocking Digital Cryptocurrencies by Andreas Antonopoulos (1st Edition)
  • Book – Bitcoin and Cryptocurrency Technologies by Princeton University (Draft version)
  • Udemy Ethereum: Decentralized Application Design & Development
  • Diginomics – Ethereum developers course (Created by myself more than a year ago)
  • IBM – Blockchain Essentials for Developers (Includes certification)
  • C4 – Certified Bitcoin Professional.



Made with love

Blockchain at Berkeley

From the oldest to the youngest. Blockchain at Berkeley was created just short of a year by a group of (mostly) undergrads from Berkeley University. Don’t let it fool you. The fact that these students are undergrads is nothing short of a plus for this program. It’s fresh, created with love, well paced, publicly available and highly recommended.

The full program is currently only available as a course (Academic credits) at Berkeley University. The program publishes its materials online. As I never had the pleasure of participating in the live program, my review refers only to what is available online.


The program structure – Beginners

The program website might be somewhat confusing at first. Some of the links are circulars, and it’s hard to find the main Education page. Pressing on the Education tab will circulate you between different live programs, workshops, and resources. The DECAL tab, which contains the (live) course assignments, reading materials, and webcasts is where you should start as it organize all of the material and resources in chronological order.

It’s my view that to understand the blockchain; one must first understand Bitcoin as it is the most researched, documented, robust and stable example of the blockchain out there. Berkeley does just this; they’re making sure that the students first understand what the blockchain Is, how it was created, how it works, and what it’s not, before moving to other implementations of the blockchain (mostly Ethreum, although hyperledger and zcash are also mentioned in later lectures).

The programs begin with the history of Bitcoin and digital money, moves to a high-level view of the protocol – from the consensus point of view and then gives a brief introduction to the crypto aspects of Bitcoin by introducing ECDSA. Once ECDSA is presented the lecture starts to get somewhat technical for many casual users (ECC properties), but not too technical that it might prevent those who are committed to start and understand how the concept of signing and asymmetric encryption. That’s by far one of the best examples I’ve seen for “mitigating the knowledge gap.” The terms are technical and well explained in a slow and forgiving pace without dummying it down.

The good work doesn’t stop with ECDSA. The next lecture: “Bitcoin Mechanics and Optimization” is another great example of how to teach some technical aspects of the Bitcoin blockchain such as double spend, transactions, and scripts (only P2PKH so far), Merkle trees, UTXOs vs. Accounts (Another great little detail that sets the foundations for the advanced Ethereum part of the program). All is presented in a professional, yet chewable way.

The program also provides an excellent top down review of mining, game theory and potential attacks. All was wonderfully constructed with a top-down view of all the relevant concepts and interesting and thought-provoking examples.  This part is also used as a bridge to introduce other blockchains (mainly Ethereum that is also the star of the next lecture)

Ethereum received only one lecture in this program, and that’s a shame. I feel as if the Ethereum lecture is the weakest one in the batch, but it’s evident that this is only due to the time limitation. The top-down review of Ethereum was good for the casual user/learner, but not on par with what the program offered so far. Many aspects of the Ethereum blockchain architecture and of the VM were completely omitted from the presentation. The decision to talk about the considerations in creating smart contracts was counterproductive, and the result is a jumble of terms and concepts that are explained in too much haste. It’s important to notice that there’s another presentation on EVM that wasn’t mentioned in the lecture

Once Ethereum is out of the way, the program focusses again on Bitcoin and presents many future ideas about it: Federated chains, switching hashing algorithm, PBTF and more. I mostly enjoyed the part about payment channels and lightning network which, together with Aaron van Wirdum’s Understanding the Lightning Network on Bitcoin Magazine, is the best resource for non-coder who wants to know how LN should work.


All of the lectures and presentations are available online at the DECAL tab. However, it’s clear that the presentations weren’t created to be a standalone learning material. It’s almost impossible to make much sense of them without watching the video, which is weird because the videos are no more than a live recording of the instructor, reading from the board. The class noises might be somewhat distracting, and it’s a shame that it’s impossible to hear the questions from the audience.


The program structure – Advanced

The materials in the DECAL tab are providing an excellent review of the blockchain with a mix of technicality and causality that can appeal to a broad audience. But for the more technical students, a more technical information is required. That is the WORKSHOP tab comes to play. Over here stored the more advanced presentations. Dealing extensively with the EVM, smart contract coding (Solidity), data architecture, math, etc.

However, as mentioned before, it’s clear that the presentations weren’t meant to stand alone. Someone needs to explain them. And unfortunately, the workshop doesn’t contain any videos. That makes most of the workshop material somewhat useless for students (but an excellent resource for educators/teachers).

Another great aspect of the program is the “Whitepaper circle.” Once in a while, the students upload their technical review of a relevant whitepaper. The videos are highly recommended.



Unfortunately, it’s impossible to participate in any way in the program (unless of course, you’re currently in Berkeley). It might have been nice to have a forum/slack for the program. I’m sure many would’ve appreciated the ability to interact with the other students and instructors directly.


Assignments and Certification

As mentioned before, there’s no way to interact with the program. You cannot participate in any way. No assignments, no certification. Only nothing. Shame.


Final thoughts

Blockchain at Berkeley was created by a group of enthusiasts undergrad students – and that only means good things about the taught material. Concise, useful, up to date, and the precise blend to appeal both to highly technical and to the more general audience.

The fact that this program was created almost as an independent side project of the said students is noticeable in its presentation. The website and presentations are beautifully done but poorly integrated into a coherence experience. I understand that when something as useful as this is giving to the public for free, it’s almost rude criticizing the way it is wrapped, but I feel as is the creators really did wanted to have something useful – a place for developers from all over the world to learn the secrets of the blockchain – the love and effort is evident to see, but in order to achieve it, some work need to be put into packaging the program.

Final note – The best program out there for technical people (coding is not a must) who wants to really understand what the blockchain is. A bit hard to find your way around it – but worth it.


Commit yourself to this program if: ·       You’re a tech-savvy person taking is first steps into the world of blockchain AND willing to put some effort into understanding the technicality of it.
Time to complete the course: ·       Thirteen weeks. Previous classes are all available on youtube and can be watched in one go
Interaction: ·       None. Too bad

·       YouTube channel. Contains all lecture videos and some whitepaper circle videos.

·       Presentations

·       Some code examples from the workshop

·       Their resource page is also worth checking out

Certification: ·       None. Too bad


ICO – Simple. Too simple.

ICO – Simple. Too simple.

important notice, please read!

This post blog is for educational purposes only. Solidity and Ethereum are bleeding edge technologies and should be treated with respect. Make sure to properly educate yourself before attempting to implement any code you might find online. I can attest that the code provided here is without a doubt not secure. It’s (at the very least) susceptible to overflow attacks, short address attacks and transferFrom double spend attacks. This is actually a very good example to my point because, while being open to such attacks, my code does adhere to the ERC20 standard. Use this code to get yourself familiarized with the basics, and then keep on learning.


All that glitters is gold.

As of April 2017, there’re 161 ICOs listed on TokenMarket, one of the leading token platforms. Of these 161 ICOs, 118 were still active. Almost every new company in the blockchain ecosystem choose ICO as its main source of fund raising.

Offering shares in the form of coins is a great way for raising funds and for potential investors to invest in many of the new and exiting new projects out there. But here’s something most don’t know: Most ICOs are nothing more than copy-past of the same code that was used in a dozen of previous ICOs – AND RIGHTFULLY SO.

The reason the same code is used again and again (with moderate variations) lies at the fact that this code was developed and tested by professionals, and it provides many useful features both to the creators of 3rd party apps (like wallets and exchanges) but also to the end users, who can be somewhat assured that the tokens they’ve just bought can be used and exchanged with relative ease.


So what’s the problem?

It seems as if many of these companies also promise (or at least gives the vague impression) that the coins that they’re offering represents a substantial part of the final product. “Buy PizzaCoin at only 57 PZC per 1 ETH and you’ll be able to use these 57 PZC in our PizzApp store.” This promise alludes to the fact that such smart contracts/apps are already developed (or at the very least are in a finale stage of development). Which is usually not the case. While I can understand those who buys tokens in the hope that in the future they might be worth more on the market (speculates) I also believe that a substantial part of the investors in ICOs hope to utilize these coins in their respective apps. They just don’t know how generic the coin really is.

Also, many of these generic contracts sometimes issue coins in a rate that has very little economic reason behind it (what does it mean to get 57PZC? Is that mean that each coin will be equal one pizza in the future? Will the price of future pizza will be determinate in a coin exchange? How do you calculate the cost of operating and maintaining a smart contract that doesn’t exist yet?).

I have absolutely no doubt that many companies actually using the raised funds in a responsible manner. They’re working hard to deliver a real final product, and I’m sure that there’re also many investors who understand that these ICOs tokens are usually nothing more than a financial assets (at least at this early stage) and the fact that they’re issued using a generic contract is not a surprise to them, but there are many others who don’t. And for them, I dedicate this post.

I hope you’ll find it useful.

ERC20 Tokens


Step one – Secure operators

Ethereum Virtual Machine (EVM) is susceptible to overflows and memory offsets. Fortunately, that can be solved quite easily by implementing some simple function to perform basic operations. Zeppelin team provided us with the SafeMath contract that provides us with the functions safeAdd, safeMul, safeDiv, safeSub and assert (The other functions are not relevant for this tutorial). Using the assert function, the SafeMath functions results are checked to make sure that they adhere to what is expected of them. For example: The function safeAdd receives two unsigned integers (a, b) and sum them together to get the result c. While both a and b are uint (not negative numbers) there’s still a chance that due to an overflow, the final result c will be lower than the sum of its components. That’s why the SafeMath function also checks to make sure that c is indeed larger then a.


Step two – ERC20 functions signatures

In late 2015 Fabian Vogelsteller, one of the mist wallet developers, suggested the creation of a unified token template called ERC20. The idea was that by providing a unified architecture for tokens – wallets creators, exchanges, and other service providers could produce a product that will support these token right out of the box, without having the need to recreate a unique wallet for each new token that is issued over the Ethereum protocol. It was suggested that the following functions will become the standard for every new token contract.

function totalSupply() constant returns (uint256 totalSupply) {}
function balanceOf(address _owner) constant returns (uint256 balance) {}
function transfer(address _recipient, uint256 _value) returns (bool success) {}
function transferFrom(address _from, address _recipient, uint256 _value) returns (bool success) {}
function approve(address _spender, uint256 _value) returns (bool success) {}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}

event Transfer(address indexed _from, address indexed _recipient, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);


While this standard isn’t fully accepted (and enforced), many token developers adhere to it as it provides them with many benefits, especially regarding interacting with other Ethereum services.

The functions signature suppose to match the basic functionality that is expected from every token smart contract.

  • function totalSupply: Display the total supply of your tokens.
  • function balanceOf: Display the amount of tokens each account has.
  • function transfer: Send value (amount of tokens) to address (recipient). The sender address is usually msg.sender.
  • function approve: Give permission to another account to trade tokens on your behalf. Used mostly when splitting your tokens to multiple wallet accounts and/or exchanges.
  • function transferFrom: Just like transfer, only in this case the user needs to specify the sender address as well.
  • function allowance: Display the amount of tokens that can be spent on behalf of the token owner by each approved address
  • event Transfer: Indexing all transactions by sender and recipient, also specify the transferred amount of tokens.
  • event Approval: Indexed all approved accounts by owner and spender account address, also specify the amount of tokens the sub spender can spend.


Step three – write your functions

Simple and straight forward. We need to start to populate our functions. Pay attention that these functions need to match the function signatures mentioned above.

mapping(address => uint256) balances;

uint256 public totalSupply;

function balanceOf(address _owner) constant returns (uint256 balance) {
    return balances[_owner];

function transfer(address _to, uint256 _value) returns (bool success){
    balances[msg.sender] = safeSub(balances[msg.sender], _value);
    balances[_to] = safeAdd(balances[_to], _value);
    Transfer(msg.sender, _to, _value);

mapping (address => mapping (address => uint256)) allowed;

function transferFrom(address _from, address _to, uint256 _value) {
    var _allowance = allowed[_from][msg.sender];
    balances[_to] = safeAdd(balances[_to], _value);
    balances[_from] = safeSub(balances[_from], _value);
    allowed[_from][msg.sender] = safeSub(_allowance, _value);
    Transfer(_from, _to, _value);

function approve(address _spender, uint256 _value) {
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);

function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
    return allowed[_owner][_spender];

The totalSupply function was replaced by a simple uint public totalSupply.


Step four – Finalizing the token

Add the following parameters to your token contract:

string public name = "ShlomiCoin";
string public symbol = "SCO";
uint public decimals = 3;
uint256 public INITIAL_SUPPLY = 10000;
uint256 totalSupply;

Insert the token constructor function:

function ShlomiCoin() {
  totalSupply = INITIAL_SUPPLY;
  balances[msg.sender] = INITIAL_SUPPLY;  // Give all of the initial tokens to the contract deployer.

And finally mash it all together to get your token contract. (Full code on Github).


Make sure your token works correctly

Check your contract by opening your mist wallet, or go to (Web interface for your ethereum node). Under CONTRACTS you should see TOKENS. Just press WATCH TOKEN and insert your token address into the popup window. You should now see that you’re indeed the proud owner of 10,000 Shlomi coins.

Pay attention, this is a standard ERC20 token, but it’s not supporting crowd-selling yet. However, making sure that your token is working and is on per with the latest standard is a significant step on the way to create a stable ICO.

Add the token address to your “watched tokens” list


Under the Send tab, you can access your tokens and send them almost as if they were regular ethers



Get yourself a cup of coffee and get ready to offer your contract to the public.


The offering

Now that we know that we have a smart contract that works and is on per with modern standards, it’s time to offer it to the public.

This step is slightly less rigid than the previous one as there’re many ways and parameters in which one ICO is different from the other. Some might place a cap on the sale; some might have a time limit on the coin offering or have a different price for each step of the sell, some might send the etheres directly to the company issuing the ICO while others might split the ethers or freeze them or even destroy them. Sometimes the buyer might get the token immediately and sometimes only after a certain time passed – You get the picture. While ERC20 attempts to provide a uniform token standard, ICOs are the wild west.

But for this example, I decided to create an ICO which:

  1. Have uniform price throughout the sell.
  2. Stays open for exactly one week since being deployed.
  3. Immediately issue the tokens to the buyers.
  4. Sends the etheres to the owner (deployer) of the ICO contract (only one address).


Step one – Creating tokens function

A simple createTokens function will:

  1. Make sure that the transaction value isn’t empty (the buyer added ethers to the transaction).
  2. Calculate the amounts of tokens to be issued (price * amount).
  3. Update the new totalSupply variable with the new amount that was recently created.
  4. Adds the new tokens into the buyer (msg.sender) balance.
  5. Send the ethers to the owner of the ICO contract.


function () payable {

function createTokens(address recipient) payable {
	if (msg.value == 0) {

	uint tokens = safeDiv(safeMul(msg.value, price), 1 ether);
	totalSupply = safeAdd(totalSupply, tokens);

	balances[recipient] = safeAdd(balances[recipient], tokens);

	if (!owner.send(msg.value)) {

This function will be called automatically when ever someone sends money to the ICO contract by using the fallback function (function ()).


Step two – Create a modifier to prevents buyers from sending ethers after the offering period ended.

uint256 public endTime;

modifier during_offering_time(){
	if (now >= endTime){


Step three – add time limit, owner address and price to your token constructor

function ShlomiICO() {
	totalSupply = INITIAL_SUPPLY;
	balances[msg.sender] = INITIAL_SUPPLY;  // Give all of the initial tokens to the contract deployer.
	endTime = now + 1 weeks;
	owner = msg.sender;

And finally mash it all together to get your token contract. (Full code on Github).

You can now launch your ICO token and interact with it using mist (or any other compatible wallet). This token will work just like any other ERC20 token with one exception if during the time of offering someone will send it one ether, which senders will receive 500 tokens into their account, while the owner of the ICO contract will get that one ether into his/hers ether account.


Simple too simple.

Two points that I want to emphasis here, the first one is that this code is extra simplistic. There’re many more features, security mechanism, distributions schemes and functionalities that can be incorporated into both ERC20 contracts and ICOs. I don’t want to disparage anyone who issues tokens and offers them to the public. This is indeed hard work that requires a lot of research, careful planing and high level of expertise. IT REALLY ISN’T MEANT FOR ANYONE!

However, the code presented here is the real thing, it’s not the best example, but that’s the scaffolding on which most ICOs are based upon. Usually, there’s no actual mechanism that will incorporate these coins into a working application/smart contract – at least not at the time of ICO.

Ethereum signature validation app

Ethereum signature validation app

Import: This article is for educational purposes only. Don’t attempt to incorporate the codes and methods presented here into working applications and don’t use keys that are associated with your real Bitcoin/Ethereum wallets.


The key pair

Key pair (Asymmetric encryption) is one of the building blocks of current blockchain solutions and cryptocurrencies, without it, Bitcoin, Ethereum and other blockchains were not possible.

The idea behind this tool is quite simple: Encrypting information using one key (public key) and decryption it using another (private key).

This short video gives a great introduction to the concept of key pairs as well as an explanation to the mathematical background behind RSA asymmetric encryption

  • Rememebr that both Bitcoin and Ethereum aren’t using RSA encryption. Instead they’re using ECC (Elliptic Curve). The mathematical background is different for the two, yet the main principle is the same.


As seen in the video, asymmetric encryption has been around for quite some time and it’s by no mean a unique feature of the blockchain. However, both Bitcoin and Ethereum (and probably many other blockchains) utilize it in a slightly different way. Rather than using the public key to encrypt a message, they’re using the private key to sign a message.

This signed message has some interesting proprieties, but the one thing what makes it really useful in the blockchain context is that the public key can be used to validate to authenticity of the signer.


original_msg = "hello"

private_key = "0x010203..."

public_key = "0x0f0e0d..."

signed_message = sign(original_msg, private_key) = "0xaabbcc..."

validate(public_key, original_msg) = True

As you can see, the idea wasn’t necessarily to hide the information (the original message need to be presented in order to validate authenticity of the signer). Instead, we use this method to prove the owner of a specific private key is indeed the one who signed the original message.

In the blockchain sense, Bob can sign the original_msg -the transaction (which is of course publicly available to anyone who have a copy of the blockchain), and by providing his own public key and the signature, everyone can verify that that specific message was indeed signed by Bob.


The validator

Originally, I planned to write some basics codes demonstrating the process in Bitcoin and Ethereum, but while studying Ethereum more in depth, I encountered the Solidity ecrecover method that returns the address associated with the signed message, and I immediately sat down to create the Validator, a simple app that uses web3.js to sign a message at the client side, and then uses smart contract to get the address of the signer (btw, the ability to display the address of the one who signed the message hints at another interesting property which I might go deeper into in another post).

The source code can be found here:

Step by step

The process was very simple, first I created the smart contract:

contract Validator{
    function constVerify(bytes32 r, bytes32 s, uint8 v, bytes32 hash) constant returns(address) {
        return ecrecover(hash, v, r, s);    
    function verify(bytes32 r, bytes32 s, uint8 v, bytes32 hash) returns(address) {
        return ecrecover(hash, v, r, s);

The contract Validator contains two functions but both are basically doing the same. The only different is that the first one is constant, that means no transaction is sent to the Ethereum network (caution! request might still be sent to a remote node if you don’t run a local Ethereum node!). This function will instantly return the address of the one who signed the original message. The other function is not a constant function, that means that a transaction will be sent to the Ethereum blockchain and the returned result will be verified by all of the users (consider the implications in terms of privacy!) the result however will not be immediately displayed to the end user – instead, in my app the user will receive the hash of the transaction. The user can then look it up on the blockchain.

The ecrecover function itself is very simple to use, all you need is the hash of the original message (hash) and the signed message (r, s, v).

The original message is hashed to ensure that uniform size, so that regardless to the size of the original message, we’ll always have a hash variable of exactly 32 bytes.

The r, s, v are all parameters of the signed message. The signed message itself (as you might already saw in the above video) is actually a combination of 3 variables.

full_sign = 0x042995e2dd996f8d234be59a623f3a2b02d3fb91187f48eaf563723b342225cc16599133550d998c880ecb1a8d29f47216f0397e30e415b95d92490f3b4ca6201b

r = 042995e2dd996f8d234be59a623f3a2b02d3fb91187f48eaf563723b342225cc //32 bytes

s = 16599133550d998c880ecb1a8d29f47216f0397e30e415b95d92490f3b4ca620 //32 bytes

v = 1b //uint8 (1 byte)

The signed message can be received using the web3.js library. I used meteor (based on nodejs) to launch my application.

Once it was launched, I declared web3 object like so:

if(typeof web3 !== 'undefined'){
  web3 = new Web3(web3.currentProvider);
	web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8080"));

The web3 is connected to metamask via chrome extension, but you can of course use your own preferred client like geth, parity or testrpc.

Once web3 is declared, getting the full signature is a very simple thing to do:

web3.eth.sign(web3.eth.accounts[0], web3.sha3(msgToSign.value), function(err, res){signedmsg = res;});

This is the full signature. r + s + v. We’ll need to break it into their component. Just remember that:

  • The first 32 bytes are the r value
  • The second 32 bytes are the s value
  • The last byte is v value (uint8)

You can read more about signature structure here

Breaking the signature into its r, s, v values is a fairly easy process that can be done with the following JavaScript code.

r = "0x" + signedMsg.value.slice(2, 66); //Treated as hex
s = "0x" + signedMsg.value.slice(66, 130); //treated as hex
v = new Buffer(signedMsg.value.slice(130, 132), "hex"); // we care for the numeric value. The Ethereum function expects uint8 and not hex.
v = v[0].valueOf();
h = web3.sha3(originalMsg.value); //we hash the original message to keep it as 32 bytes, regardless to the input size.

Now the only thing that is remained is to send these values along with the original message to smart contract, and get the result back.

Validator.verify(r, s, v, h, function(err,res){         		
    Template.address.set("The transaction id is: " + res);

Validator.constVerify(r, s, v, h, function(err,res){
    Template.address.set("The signer address: " + res);

The final result (The site isn’t secured. Don’t sign anything of value!)

Signing and validating message in ethereum


Mixing environments – Creating working environment for blockchain developers

Mixing environments – Creating working environment for blockchain developers

This article is part of a series of articles depicting my experience with creating and conducting an 8 week long blockchain app development course in Brazil.


What tools should be used when teaching blockchain


The term blockchain is often misused. Very rarely do people use the term blockchain to describe anything beyond a chain of blocks. A lot of the time when people talk about the blockchain and its application, they basically refer to a somewhat wide variety of technologies, architectures, tools and protocols that, once properly combined and implemented, creates that “blockchain” they are referring to.

When I created the course, it was obvious to me that in order to properly teach the students how to work with “the blockchain”, I’ll first need to spend a lot time dealing with many different technologies and tools. There isn’t just one blockchain IDE or concept to examine; rather there are quite a number of them. Take key pair for example; private and public keys are some of the most crucial (and known) features in many crypto-currencies and blockchains, but they are by no means specific to blockchains. Many people use key pairs off chain. The same holds for many concepts that are highly integrated into the common view about blockchains – Hashing functions, signatures (and keys), scripts and stack architecture, byzantine general problem, bytes codes, merkle trees, DAGs and more.

Each feature in the list above represent another tool/approach/use case/concept that stands by itself but is also crucial to creating what is commonly known as “the blockchain”. This fact posed a great challenge for me when I tried to create the course. It was obvious to me that the course is aimed at people who want to learn how to develop their own blockchain applications and solutions, which meant that it will require the students to get their hands somewhat dirty in codes, command line prompt, and different computational tools.

The challenge here lay in choosing the right tools to work with while remembering that each item on the list should be taught in a manner that is  adequate on the one hand, but without going to a level too deep and insignificant for the course on the other hand. It was also important that there should be a clear difference in the relations between the different and individual items.  I knew I wasn’t hired to teach the students how to program or how to work with different environments. However, making the assumption that they had adequate programming knowledge, enough not to require any introduction to that programing language/ environment/ tools seemed quite optimistic at best, and downright stupid at worst. This is even more so when dealing with a variety of different tools and languages.

I decided to do my best to choose the most user friendly working environments – even at the cost of efficiency and future usability.

Numerous developers have their own working environment. However, I was convinced that every code, example and CLI command/tool should be properly tested and documented in a single uniform environment. The last thing I wanted to do was stand in front of the class while in the background, my code failed to compile. The result of this is that I tried  a lot of different environments while always keeping in mind that the environment to be used should fulfill the following requirements;

  1. It needs to support all the tools I require that my students use.
  2. It shouldn’t affect in anyway the students’ computers, working environments, file systems, paths and/or jeopardizes their computer security in any way.
  3. It should be uniform for all the students.
  4. It should be easy and fast to set and reset whenever needed.
  5. It should be as user friendly as possible.


After a few experimentations, I decided to work with the following configurations:


  1. Cloud9 level 1 IDE environment with the following installations:
    1. Python-pip.
    2. Python-virtualenv.
    3. Virtual environments for Python 2.7 and 3.5
    4. Ethereum SOLC
    5. Tcpdump (for some reasons, not all c9 workspaces had it installed)
    6. The following pip packages (base58, ecdsa)
Cloud 9 was used for running python files and as a uniform terminal.
  1. Digital ocean Ubuntu 16.041 X64 droplet with the following installations:
    1. Nodejs 6
    2. Meteor Javascript framework version 1.3.4 with web3 and bitcore-lib packages.
    3. The following changes were optional for a few students:
      1. Installing ipfs and running ipfs daemon and adding ipfs-api package to their meteor app. (For those who wished to work with IPFS).
      2. Adding swap file of 4 gb. (For those with memory issues).
  • Use openssh. (More IDE flexibility for advanced users).


  1. Solidity browser compiler was mostly used for writing and deploying smart contracts. SOLC (installed on c9) was used by a few students who required some more advanced contracts (mostly when containing libraries).


  1. The only 2 components the students were required to install on their own machines were:
    1. Chrome/Chromium with metamask addon.
    2. Wireshark.


Cloud9 provided a well-tested and easy to configure working environment that was consistent for all students. It was used mainly to run the Python codes the students created, to compile some Solidity codes (using SOLC), to catch some packets using tcpdump (The tcpdump files were later downloaded and examined using wireshark) and to access digital ocean droplet using ssh.

I was very pleased with this working environment as it was quite robust, highly configurable, not local and easy to reset – Basically it was a great playground to get dirty with, without having to worry about damaging the students’ native environment.


Digital ocean droplets were used to provide the students with a uniform platform on which they can create their apps. Meteor is a well-documented JavaScript framework. It was obvious to me that if the students were expected to create applications, they should also have access to some JavaScript tools as both Bitcoin and Ethereum have some very powerful tools for app developers – mainly web3 for Ethereum and Bitcore for Bitcoin.

There’s also another npm package for compiling Solidity (similar to SOLC), but unfortunately, I’ve experienced a lot of compatibility issues with that package and decided to ban the students from using it. IPFS-api is another useful tool for more advanced students who are interested in working with IPFS.

It is important to note that although I did discuss IPFS with some students, I didn’t consider it an important part of the course. First, the system is still in a very early stage. Secondly, the main goal of the course was to teach the students how to develop blockchain applications, and not necessarily decentralized applications (although the two might have a lot in common, they’re not mutually the same) and IPFS just didn’t really fit the slot. Besides, I already had an ample amount of topics to focus on and teach my students (And I must admit; I’m not that much of an expert in this platform myself).

Another point to consider is that in a future course, in the case where there’s no promise to create apps, digital ocean might still be used. In this case, JavaScript libraries can be taught by using clean nodeJS interface.


Metamask and solidity browser were wonderful and very easy to use tools. In a manner of minutes, the student had yet another playground to play with Solidity and the Ethereum blockchain.

(It’s important to note that I took some time to make sure ALL of the students were using clean metamask installation WITHOUT any of their real wallets imported to it and only on the Ropsten testnet).


One last note about truffle

I also feel compelled to justify a little further my decision to exclude the use of truffle and/or embark (with testrpc) during the course and instead choosing to work with solidity browser compiler. The thing is,  at the time, both truffle and embark had some memory issues that forced me to use another swap file (both when tested on Cloud9 and when tested on digital ocean droplet). In addition to that,  most smart contracts required were easy to deploy from the Solidity web compiler. For specific ad hoc contracts that required the use of a more robust compiler, Ethereum SOLC was used on cloud 9 (SOLC didn’t had any memory issues). I do however recognize that truffle and embark are major tools in the industry and I’m defiantly planning to integrate them into future courses.

What to teach when teaching blockchain

What to teach when teaching blockchain

This article is part of a series of articles depicting my experience with creating and conducting an 8 week long blockchain app development course in Brazil.


The course as a mega structure

After I accepted to take on this challenge, the next logical course of action was to create the listof material I intended to teach the students. Originally, this list contained almost everything blockchain related – from bits, bytes and creating protocol messages all the way up to an overview of the history and politics of Bitcoin. The list was long, perhaps too long. I must admit my own limitations- I couldn’t see any realistic way to create such an extensive course by myself.

In addition, I had some doubts as to how many students can actually properly digest so much material, even when given 8 full weeks. (6 actually, if you count the time given to personal projects). I realized the list needed to be more focused – and that’s where my first major decisions were made.


Decision number 1: Focusing on the protocol itself. By deeply understanding the Bitcoin (and later the Ethereum) protocol, I believed the students will gain some clarity and very strong foundations upon which they can later build on and learn more extensively by themselves.

It was highly important to me to ensure they actually understand the protocol itself – how it developed, the tools it utilizes, and the logic behind choosing these specific tools and architectures and so on.

Once the students understood the intricacies of dealing with it, they will be better equipped to learn by themselves other things like how to use JS libraries in web applications; read and understand whitepapers and BIPs/EIPs, and create their own private chains and more. But how do I teach the protocol? That’s where my second decision was made.


Decision number 2: Bitcoin is the gold standard of blockchains and therefore, the go to chain when learning the basics of blockchains. This decision was a no brainer for me and represents a substantial chunk of my personal view on the blockchain ecosystem. The Bitcoin blockchain is the most widely used, heavily researched and extensively documented (albeit the documentation is somewhat lacking in my opinion). Every blockchain in existence this day stemmed from it and relies to a large extent on many of the concepts introduced by it.

It was clear to me that creating a blockchain course that isn’t based on the Bitcoin protocol will be a major breach of the faith the students reposed in me.

These two decisions brought with them peace of mind. Whereas before I was drowning in a pool of topics to cover – a list so long and chaotic, it was completely unmanageable, I now had a solid anchor to work with.



The four stages of mastering the blockchain

Once the list was completed, it became clear it could be divided into 4 main stages or phases:

The basics

From bit and bytes to protocol messages. The idea is that once completed, the student is able to send, receive and (maybe most importantly) parse a Bitcoin protocol message. In order to achieve this, the students will need to learn the basic mechanism of networking, create the byte code for a Bitcoin message – both payload and header, learn how to use one-way functions, hashing and how to read and understand the Bitcoin developers guide and protocol documentation.

Here, I held enlightening conversations with the students that revolved around keys. We went through the documentation together in a bid to learn about how to move seamlessly from private key to the public one and onto Bitcoin address.


The bread and butter of the Bitcoin protocol. Now that the students have the understanding of how to work with the Bitcoin documentation, the next logical step was channeling that documentation and using it in creating transactions.

Here, the students will garner all their knowledge about bits and bytes, hashing and keys (from the previous stage) and channel it into creating the raw Bitcoin transaction. After which, they will learn about the pkScript; scripting in Bitcoin (and scripting in general) plus stack architecture and how the pkScript is executed, which by the way is also a great opportunity to start the conversation with the students about Ethereum and its virtual machine.


Finally, the students will go on to elucidate on what type of transactions are considered standard.


Blockchain architecture

After speaking with the students about all the basic components required in creating and transmitting a Bitcoin transaction, it was time to move on to talks about blocks and their architecture. I wanted them to have an understanding of what blocks really are. We were to create merkle trees (and merkle roots), blockheaders, calculate (mock) difficulty and target, and find the proper nonce. Along with that, it was also a great chance to have a chat with the students about DAG and consensus, mining algorithm, forks and altcoins.

In this phase, I was also afforded an invaluable chance to have a discussion with the students about contracts and secondary layers such as lightning network and BIPs (SegWit, addresses and other bips).


This is the second most predominant chain out there. It includes the wild west of consensus rules, mining algorithms and script (VM) playground. Many students want to understand how it works, and rightfully so. However, what most students want in learning Ethereum is how to actually use it – how to write smart contracts, and hence, how to use Solidity. This is where my previous decision to focus on Bitcoin as the gold standard for blockchain architecture became two opposite things; a blessing and a curse.

I wanted to spend as much time as I possibly could on Solidity, Web3 and Ethereum specific tools, and since I already spent more than half of the course talking about blockchain and Bitcoin, I was freer to talk about Solidity and web3 in this part of the course. However, a compromise was made and several unique architectural aspects of Ethereum were left out. I briefly talked about gas and the EVM by tying it to Bitcoin scripts and fees, and I glossed over block structure by simply stating that “merkle roots are also involved”. Mining and Ethereum attempts to move to POS were completely ignored – I think you get the picture.

The only architectural aspects of Ethereum I discussed in class were the ones that can be easily seen when playing with Solidity and smart contracts (Libraries and calls, Inline assembly, variables gas price, constant functions, variables scopes etc.)


I used this general scheme to select the topics to be covered in the Bitcoin part of the course


A sense of achievement

All in all, I’m quite proud of this structure and the topics it included. I found myself with a solid and detailed road map of the course. It was clear to me and to a lesser extent my students where we are now, and what is yet to come. I also hoped to use these 4 stages as the basis on which I would create semi-official certificates for my students. The idea was that every 1.5-2 weeks or so, the students did manage to achieve something very meaningful.

On completion of the first stage, the student managed to establish connection to a remote node on the Bitcoin network, and created key pairs and Bitcoin address.

On completion of the second stage, the student proved that he/she possesses a deep understanding of how Bitcoin transactions work. Things like how to hash a transaction, how to deal with TXID, how fees are determined, how (and when and where) signatures are used in the protocol and how the Bitcoin scripting language works. All of these gave the students a platform to create the bytecode for their own transactions (P2PKH and OP_RETURN).

At the time the third stage was completed, the students had managed to create their own block by creating the merkle tree and finding its root, calculating (mock) target, creating the blockheader and eventually finding the right nonce (Important note: I didn’t ask the students to create a coinbase transaction, although we did talk about it and examine its structure, but I believed adding another type of transaction will only serve to confuse them).

The final stage, the Ethereum stage, was in fact more of free working sessions. As I mentioned earlier, one of the requirements was that the students will have time to create their own dApps. Each student was working on his/her individual projects and as long as they managed to get their smart contracts to work, they managed to complete this stage.

(More details on my experience with the certification system in the coming articles).



So how did it go?

The first part of the course went rather smoothly, either because the students were still very eager to learn or because it was truly well constructed.

However, owing to some technical problems, I did not receive the certificates on time which placed me at a somewhat awkward position. Not only did I make a promise to my students that I’d give it to them, I was also quite worried that in the absence of something more tangible, they might not properly appreciate their own progress during the course.

This fear continued to be my shadow through the duration of the course as I tried to motivate my students to continue their hard and not so rewarding work. Right at the end of the course, I did manage to receive some documentation I could give my students and the response was very positive indeed. I’m now more convinced than ever that providing a proper certification at the end of each step can reduce much of the stress and hardship associated with such a demanding course. As a matter of fact, one of the major decisions I made at the end of this course was regarding certifications.

There was a major criticism I received during the course in relation to the course structure. A good number of the students, while not showing any major problem understanding the granular topic of the day and implementing the codes did have a hard time seeing the bigger picture. The structure I created aimed to look at the blockchain from a very close distance while working with some of its finest components.

I did try to encourage additional “free conversations” in class, hoping that during these less formal chats the students will utilize what we learned But soon it became clear to me that the timing of these free conversations, their length and their focus (or lack of it), was quite counterproductive. Therefore, I needed to come up with more appropriate time slots for such informal class sessions, while making sure to be well prepared with case study in case the students will not be focused. . For example, it might have been productive to try and talk about SigWit during the transactions class instead of only at the end of the Bitcoin portion of the course, even though the students didn’t yet learn about merkle trees, blocks architecture and BIPs.

The students were vocal about their desire for me to focus more on the big picture. This was in addition to some external pressure placed on me to start working with the students on their own personal projects. All of these led me to the production of some minor (yet quite meaningful) changes to the structure, mid – course. Basically, the border between the third stage (Blockchain architecture) and the fourth (Ethereum) was less strict than I wanted it to be.

It is true I already planned to use the third stage as a transition stage (as mentioned above, a substantial part of the Ethereum architecture was glossed over by comparing it to the Bitcoin blockchain). I did plan to talk about Ethereum quite extensively at this point (Ethereum was supposed to be mentioned first at the end of the second stage- transactions stage- right when the students learned some standard pkScripts). I still wasn’t well prepared with a suitable road map to make this diversion from the predefined curriculum.

The final result was that the transition from Bitcoin to Ethereum was lacking at best, if not somewhat confusing. This experience, while being somewhat hard in real time, did help to solidify my own confidence in the structure of the course – at least in its higher level and I’m much less inclined to perform similar deviations in future courses.

Another veritable source of confidence is the progress many students showed. A small, yet substantial, part of the class came on board with little to literally zero experience in programming and blockchains. Yet, by the end of it, I did witness some highly impressive progress in their abilities and understanding while the more advanced students also managed to create some impressive codes, smart contracts and even to construct a few apps. Ultimately at the end of the day, that’s what matters the most.

Teaching blockchain in Brazil

Teaching blockchain in Brazil

What is it all about

A few months ago, I received an interesting email from a company I didn’t know at the time. What was the content? I was asked to create and conduct a full fledge, 8 weeks long, blockchain development course in Brazil that would involve students from all walks of life.

Blockchain education is something I am passionate about, so this offer immediately struck a chord in me. In the past, I have talked a little on how I got into this field and given some insights on my views about the current ecosystem in terms of education. To sum it up; there’s an existing huge knowledge gap that serves to keep many talented people from properly contributing and utilizing numerous blockchain based solutions.

The deep-seated desire to bridge this gap is a major part of my personal agenda. For that reason, in the past, I created a few videos and tutorials (which owing to the fast paced nature of technology are in sore need of an update, I know) that were aimed at mitigating this gap in knowledge and making blockchain codes somewhat more reachable for developers and tech people who are new to this ecosystem. In addition, I was looking for other ways to bring Bitcoin and Ethereum to the people. In line with this, a creating/conducting course seemed like the logical next step.

In the early chats that transpired between me and the Brazilian company, I was offered the freedom to construct the course as I see fit, without any restrictions.  There was one specific request – that when the duration of the course comes to an end, the student will create their own apps. Considering the proposed length of the course (8 weeks), I believed  it would be quite easily achievable simply by allocating the last 2 weeks of the course to exclusively working with the students on their personal projects.

As we talked about the projects the students might create during the course, we also discussed the lack of needed quality in many of the current blockchain related projects out there.  I gave my impression that it was due to a dearth of understanding of blockchains. Most projects are nothing more than basic apps that have very little to gain from using the blockchain and are either utilizing it for marketing reasons – basically to draw more investors’ money owing largely to a lack of understanding on the investors’ side.

But this is not all; it could also be as a result of a serious flaw in their understanding of how to use the blockchain from the creators’ side. I wanted to ensure the students really have an understanding of what the blockchain is, and equally important, what it isn’t.

My counterpart was impressed by this approach and it became clear to the both of us we were seeing eye-to-eye on what our vision for the course was.


Getting ready

Working on the course took a substantial part of my time for the better part of 2-3 months. I basically started creating a course from scratch as there were very limited resources and existing courses to draw from. I created a course structure, list of topics, codes and other teaching aids. The task was a hard one, harder than I initially anticipated. I basically, single handedly tried to create one of the most ambitious courses using nothing but my own means and with literally no support of any kind. But I made it!

Slowly but surely, I managed to create a list of working codes to teach my students. I had a solid course structure, the basic infrastructure for a certification system, few assignments, list of resources, presentations and a lot of notes – all corresponding and completing each other, tested and organized for maximum effect.


In Brazil

It was finally the moment of truth. I arrived in Brazil with my course (mostly) neatly organized and prepared. The time for theory was past and it was  time to see it in real action and put my work to the ultimate test.


Some curious Brazilian horses that participated my class.


The final experience in Brazil was much more challenging than I thought it would be. Some of the difficulties I encountered were related to the technical background and level of the students (the class was very heterogeneous). While some had extensive experience, others had absolutely zero previous experience.  A number of the challenges were related to my own preparation for the said course.

Still, when the course winded to an end, I was highly pleased and proud to see how ALL of the students managed to show great advancement.

I’m very grateful for this experience. I had the opportunity to create a full fledge course, a unique and solid one that provides substantial blockchain education, an element that is sorely lacking outside of very specific programs in selected universities. The challenges I encountered during the course were also a great blessing; my course (and by extension, my whole approach to blockchain education) was tested rapidly and almost every aspect of it was subjected to stress test, and it made it through!

Additionally, this course was a great learning experience for me. As a matter of fact, I’m already working on implementing some of the things I’ve learned in order to provide even better learning resources and courses in the near future.

Now, almost a month after the course, I decided to sit down and articulate my thoughts and experiences. It is my wish to share what I did and what I learned. It is my hope that by doing so, I might be opportune to effect some positive impact on the blockchain education ecosystem and that these articles will be helpful to many.

The articles are currently divided into 7 major categories:

  1. Course structure.
  2. Choosing the working environment.
  3. The codes that were presented and exercised.
  4. Certifications and accreditation.
  5. Teaching aids.
  6. Assignments, homework and evaluation.
  7. Others (students’ background, learning environment, marketing and setting expectations, class size, after class meetings etc.).

These articles will be published in parts in weeks to come.