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).
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.
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!
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
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 needmigrations
: Contains scripts describing the steps of migrationTimeLock.sol
: Includes the ÐApp codetest
: 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.
is thesol factory
contract which lets anyone easily deploy their ownTimeLockedWallet
.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.
- 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.