Down the Rabbit Hole of DApps, Smart Contracts, and Blockchain Technology

Blockchain Development Mentors continue to expand the capabilities of information processing by teaching Chicago Developers how Ethereum funds, assets, certificates, and or information can be stored with TimeLockEncryption by building a Smart Contract, also known as Decentralized Application (DApp) .

There are many different smart contracts applications built with Ethereum Blockchain. Popular ones are cryptocurrencies at the moment (implemented as ERC20 tokens) and crowdfunding token sales (a.k.a. Token Generation Event, or TGEs).

  • Facebook
  • Twitter
  • Buffer
  • reddit
  • LinkedIn
Milwaukee Blockchain Developer — Nicholas Resendez, and South African native Chicago Blockchain Developer — Shane Van Coller, and Founder of DApperNetwork — Eric Chung, showcase a DApp Smart Contract built and launched using the Ethereum Blockchain. Pictured Left: Eric Chung, Founder @DApperNetwork | Right: Eric Lim, Founder @DApperNetwork

Think of something different: The idea of locking funds (assets, certificates, and or information) in ethereum wallet contracts. This idea itself has various use cases.

TLE is a simple time lock contract where funds, Ether (ETH), committed to the contract will be locked for the specified period of time which, once elapsed, can be withdrawn again.

Alternative Ideas: A Trust Fund, 401 (k), or CryptoStash

Locking funds enables one to create a small trust fund or time-based savings account, one that prevents the creator / owner from withdrawing information (ether) before a certain time in the future.

It could be particularly useful for crypto traders to stash profits in helping keep their ether intact. The use case we decided to explore and teach was to put some crypto-money away for later for someone else, like a future birthday gift.

Let’s imagine we would like to gift one ether to someone for their 18th birthday. We could write down on a piece of paper the account’s private key or use Civic to store the key to an identity. The wallet holding the funds and hand it over to them in an envelope. The only thing they would have to do is call a function on the contract from their account once they are 18 and all the funds will be transferred to them. Or, instead, we could just use a simple ÐApp. Sounds good? Let’s get started!

  • Facebook
  • Twitter
  • Buffer
  • reddit
  • LinkedIn

Ethereum Development Education

Before you jump ahead with smart contract development, you need to learn the basics. Checkout DApperNetwork Meetup page for an event near you.

Now lets make sure we have Node.js and Git installed on our machine. We will be using the Truffle framework. Even though you can do without it, Truffle significantly reduces the entry barrier to the development, testing, and deployment of Ethereum smart contracts. Per their statement:

“Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier.”

Alternative Setup: Remix Ethereum

  • Facebook
  • Twitter
  • Buffer
  • reddit
  • LinkedIn
Remix is a code pad and compiler used to develop solidity smart contracts.

Install Truffle

To install it, run the following command:

npm install -g truffle

Now, get the code of this project:

git clone https://github.com/nirholas/TimeLockEncrypt/ 
cd TimeLockEncrypt

It is important to note that the project follows the standard Truffle project structure and the directories of interest are:

  • contracts: Holds all the Solidity contract we need
  • migrations: Contains scripts describing the steps of migration
  • TimeLock.sol: Includes the ÐApp code
  • test: Stores all the contract tests

Description of the Smart Contracts

There are several contracts included in this project. Here’s the rundown:

  • TimeLockedWallet.sol is the main contract of this project and it is described in detail below.
  • TimeLockedColdWalletFactory.sol is the factory contract which lets anyone easily deploy their own TimeLockedWallet.
  • ERC20.sol is an interface of the ERC20 standard for Ethereum tokens.
  • TLEToken.sol is a customized ERC20 token.
  • SafeMath.sol is a small library used by TLEToken for performing safe arithmetic operations.
  • Migrations.sol is an internal Truffle contract facilitating migrations.

For official information on Ethereum contracts, please refer to the official Solidity docs.

Decentralized Application Setup

In order to run a ÐApp, you will need to have an Ethereum-enabled browser. This includes the Brave Browser and Google Chrome. The easiest way of achieving this is to install the MetaMask Chrome plugin.

Smart Contract Scenario

Let’s assume Account 2 is going to create the time-locked wallet and Account 3 will be the receiver/eventual owner of the funds.

  • Facebook
  • Twitter
  • Buffer
  • reddit
  • LinkedIn
Pictured: MetaMask
  • Account 1 creates a time-locked wallet for Bob and sends some ETH
  • Account 1 additionally sends some ERC20 TLETokens
  • Account 2 can see the wallets he has access to and the ones he created
  • Account 2 cannot withdraw any funds before the wallet’s time lock expires
  • Account 2 withdraws the ETH when it gets unlocked
  • Account 2 withdraws all ERC2TLETokens

The world beneath the Blockchain and smart contracts is full of code and technical knowledge. It’s time to journey down the rabbit hole to understand as much as we can about the technology we so openly advocate for.

  • Facebook
  • Twitter
  • Buffer
  • reddit
  • LinkedIn

Previous ArticleNext Article
Nicholas Resendez
At 21 years old, Nicholas is an established Data Scientist, Web Developer, and Blockchain Mentor with a passion for learning about Information Security.

Join Our Mailing List

Keep up with the latest in FinTech, Blockchain, and Crypto.

You have Successfully Subscribed!