Welcome to the Wild Wild Web3

Build Your Own Crypto Incentive Schemes. Take your blockchain project to the “real world”

Disclaimer: I’m hosting a free Bootcamp with Elk.cc, I hope this post excites you to dive deeper into learning about blockchain and IoT with me!

The picture above is a photo of people at the Elk office, where I work, they are doing pushups competing for a crypto token I made called the ELK Coin. Is the ELK coin worthless? Perhaps, although I sometimes offer people favors if they send me some. The curious thing is the dynamics that start taking place when you make a claim of value and have provable transactions.

What sorts of incentive schemes can you design when Smart Contracts connect with embedded systems? These are some of the questions I’m opening up with my provocations at Elk and I am opening it up for a larger dialog with this blog post and the bootcamp I will be running next week.

The best way to understand a transforming world is to be a part of developing it. In this tutorial I want to go through my process in helping me build mental models about the decentralized web, sometimes known as Web3. This tutorial will help you build a decentralized mindset while taking you step by step in building your own token based office incentive scheme.

Web3 brings with it a few new abilities, let’s break down what that means:

Matrix of new abilities

Rather than a bunch of facts, let’s break it down practically. by making our own Ethereum based crypto-token and create awesome incentives by gamifying the Elk office. To join in on this adventure, you will need:

  1. Your own ethereum wallet
  2. Some ether (the currency of ethereum)
  3. 30 mins.

Step One — Get A Wallet

Get a wallet, the easy way:Install the Meta Mask plugin for Firefox, Chrome or use the onboard plugin in the new Brave browser.For step by step details on how to do that please follow this great tutorial.Get a wallet, the mathematical way:

Some amazing mathematics underlies a lot of the special abilities that are now possible to do with the world of Web3. Although you don’t need to understand it to be able to use it, the reason I am including this here is that it’s imperative to intuit how it all works without central servers managing the addresses. And because learning is awesome!

For Ethereum, you are using the features of beautiful graph:

to generate a public/private key pair. A keypair allows you to share secret messages with people online and also to prove that you intended to sign digital files. This lies at the heart of decentralized tech and we want to be sure that you don’t miss out on understanding it. Ethereum’s addresses are derived by taking a hash of the public key. A hash is a function that creates a unique fixed length string from various inputs.

If you’d like to generate your own Ethereum address by generating your public/private key pair and hashing your public key, you can follow this tutorial, the code here. If you’d like to nerd out a little more on how you can create a one way function from the elliptic curve above, read this.

The public/private key pair is an essential element of unlocking your wallet and sending funds, connected to the identification of your Ethereum address, and is how you can sign and prove intent since only you have access to these keys. So keep em safe!

Step Two — Get Some Ether.

So by now you should now have a funny looking string of numbers like: 0x21aB0B3527326dcA4469245654Cf881F5F7a8c5e

A unique feature of writing and interacting with the blockchain is that since you don’t own the computer running the code and you’re not paying for a hosting server to run the code for you you’ll have to incentivize the decentralized network to host and run your contract. That means every time you want to publish or run your decentralized code, you need to pay for it. So, let’s get you some test ether to play with.

Click your Meta Mask icon to open up the plugin. Click the top area that says “Main Ethereum Network” and change it to the “Ropsten Test Network” then can head here: https://faucet.metamask.io/ and click “request one ether”. Once the transaction is complete, click the Meta Mask icon and check out your brand new shiny ether!

Step Three — Publish your contract.

Amazing! You have your wallet, you have your ether, now let’s make our token contract! As we mentioned previously Ethereum is a platform which has its own native coin that goes by Ether. Ether can be viewed as the fuel which runs contract code living on the blockchain. Since we are using computational resources from other people’s computers using arbitrary code lengths we need a way to charge a variable amount. This amount is called “gas” — analogous to the gas you might put into your car to make it go.

To make our own incentives scheme and currency for the Elk office, let’s consider what functions and features may be necessary:

  1. Limited supply of tokens to create scarcity
  2. Tokens can be sent and received
  3. Number of tokens in contract can be viewed…

Now we can take each of these features and write our own smart contract, although since this code is also managing tokens that may have value at some point it’s best to use audited contracts that take into consideration loopholes and bugs that we may inadvertently introduce.

Open Zeppelin has created an open source and audited implementation of the ERC20 standard. The ERC20 standard has previously been discussed by Vitalic, the founder of Ethereum, on github, on the community forum reddit and elsewhere before it settled into its current shape. The reason I mention this history is to emphasize that the design consideration for standards are communally generated and your voice matters!

So, now that we know a bit about the background of ERC20, let’s make our first token!

First open the remix editor in a separate tab. Now to keep things simple, I’ve gobbled together the code from all the various modules from the Zeppelin implementation of the standard into one code blob to make copying and pasting simple. You can find that blob here in this paste bin. This is all the code required to make your own token. Copy this file and paste it into ballot.sol in the remix editor, you can rename this file exampleToken.sol, or whatever you’d like.

To prevent errors, it is best to select the compiler that matches the code, you can see that on the very first line: “pragma solidity ^0.5.2;” — choose the 0.5.2 commit from the “Select new compiler” drop down.

Now let’s customize your token for your application. Scroll down to the bottom of the code I shared and find this section:

contract SimpleToken is ERC20, ERC20Detailed {
uint8 public constant DECIMALS = 2;
uint256 public constant INITIAL_SUPPLY = 1000 * (10 ** uint256(DECIMALS));
constructor () public ERC20Detailed(“SimpleToken”, “SIM”, DECIMALS) {_mint(msg.sender, INITIAL_SUPPLY);

You can change the name from SimpleToken and the short name SIM to whatever you’d like. Then you can modify the INITIAL_SUPPLY variable to be however many tokens you want, DECIMALS to however many decimal places you want after it. For instance if you want 10,000 tokens that can be divided into “pennies” you can say 10000 for the supply and 2 for the decimals.

This way, once you deploy your contract, your total supply function will return: “1000000”, and your DECIMALS function will return: “2”. Hooray!

Now we are ready to publish your contract! Follow these steps carefully:

Right underneath the compiler selector you will see a button that says “start to compile”, if it hasn’t already compiled your code, please push this button.

Next, click the “Run” tab in the upper right corner of your window. Select Injected Web3 (this means Meta Mask for our purposes) and lastly be sure to pick the name of your token as the contract to publish. If you haven’t changed the code, it should be called SimpleToken, if you have you will see your token’s name here. Don’t worry about the other names (ERC20, SafeMath, etc…) it will refer to the other compiled contract modules as it needs, we only need to run our token’s contract.

Now comes the fun part! Playing with your token and sending some to your friends!

Add your token to Meta Mask!

Once you hit deploy, it will be deployed using the account selected in the drop down above, it should be the one that you created and fueled with Ropsten Ether. The Meta Mask plugin will pop up and ask you to confirm. Now since this is going up and actually going to reside on a living test network it will take some time for the miners to confirm your transaction, please be patient. Once it’s confirmed, that means you paid enough gas for the miners to deem adding your code to the block worthy. Hooray! You should now see a confirmation in the debug window.

Scroll down in the “Run” tab and you should see your token in the “Deployed contracts” list. Open it up and you can start clicking on the blue colored buttons to interact with your contract.

To be sure your contract is up for the world to see, look inside the debug screen for your Etherscan link. Etherscan link is a viewer for the content publicly viewable on the blockchain.

Hello Nur Token

Here is my link for my newly created Nur token.

You will probably want to use Meta Mask to send and receive tokens more easily and to help others also send/recieve tokens. First thing to do is figure out what your contract’s address is. This is important to note, your contract’s address is not your address. It is its own entity which if programmed can make its own decisions. You can find your contract in a few places:

  1. Inside the remix editor, right by the name of your deployed contract is a “copy” symbol, pressing that will copy the contracts address to your clipboard.
  2. If you go to the Etherscan page from the debug console, you can see the contract address in this form: “[Contract 0xc84a29bf11934172131067503a5762aa19d18429 Created]”

Copy your address and click on the Meta Mask plugin. Click on the three bar sandwich icon on the upper left and scroll till you see “Add Token” on the bottom. Click it and then on the next window select “Custom Token” and add the contract address you copied from the previous step. It should automatically fill out the name and number of decimals. Once you click next you’ll see your account is now set up to send tokens!

So now here is where the fun starts. The incredible thing about these tokens is that when you send them to others and once they own them — you can no longer take them back. They can prove to the world they have them on etherscan, all without having to trust a central server, a bank, or even the person who made the token! This opens up avenues for exploring incentivization schemes and games. I am using the ELK token I created at the office to challenge the team here to walk up the stairs, solve puzzles, and other fun tasks and I send them ELK in exchange.

Photographic proof of coming to the office early:

And “proof of workout”:

Next steps:

This is only the beginning. Currently I am coordinating documenting challenges people propose and the completion of those challenges in a shared spreadsheet and verifying using photos and conversations in the office, lots of in-person trust.

This is a centralized point of failure, not automated, and isn’t distributing incentives to the whole team. Not to mention I personally am bottleneck needing to be sent evidence of actions and needing to go to Metamask and send everyone the right amount of our token. I’m proposing to expand the office gamification project using an ERC721 token specification. Do you have thoughts on how to create a better system? How would you create an in office token gamification scheme?

Most importantly, with these new super powers that the technologies that power Web3 unleash, what will you create? What happens when we connect self executing code with electronic systems? The verification that can be proven on the blockchain gets messy when you’re dealing with hackable electronics. What can we do about this? These are open questions and I’ve set up a short bootcamp to help people curious about Blockchain and IoT to develop the basic skillset to start interrogating the space.

To learn more and join our free 3 week bootcamp, check out elk.cc/bootcamp

I’m the host of the workshop and I also work for Elk, a company making an open source board to simplify connecting the physical world to the blockchain world. Excited to have you join our learning journey!

Schedule of events, join us free at: elk.cc/bootcamp

I hope this tutorial has whet your appetite for learning. The intersection of blockchain in the real world to affect incentives, create and share digital/physical value and lead to trusted human-human, human-computer and computer-computer transactions is going to grow once the blockchain connects with embedded systems and IoT. What that world looks like, we don’t know. What I do know is that it needs more voices from people willing to learn, experiment and build these systems and that’s what this tutorial and the bootcamp is all about. Can’t wait to open up a can of works with you!

Warmly, Bilal Ghalib

Welcome to the Wild Wild Web3 was originally published in Hacker Noon on Medium, where people are continuing the conversation by highlighting and responding to this story.

Publication date: 
06/19/2019 - 22:26

The views and opinions expressed in this article are solely those of the authors and do not reflect the views of Bitcoin Insider. Every investment and trading move involves risk - this is especially true for cryptocurrencies given their volatility. We strongly advise our readers to conduct their own research when making a decision.