This Ethereum is an incredible platform. It enables anyone and everyone the power to play with programmable money like never before. Thus far the project has been relatively inaccessible to users that are not highly technical… Until now.
Alex van de Sande and Fabian Vogelsteller have recently given us the Ethereum Wallet: probably the coolest wallet in Crypto. With their simple graphical user interface, finally non-developers can work directly with Ethereum, building tokens, DAOs and crowdfunding campaigns without needing to use the command line!
Warning! It is not the best or most efficient code, don’t use my smart contract as a model to build real smart contracts! Alex van de Sande rewrote this contract using a third as many lines of code, but my version was used for this tutorial because it’s easier to understand for us non-PhD’s.
The smart contract that we use in this tutorial is a very simple notary-type contract that’s designed to simplify the management of a Will by decentralizing Will verification. The contract’s purpose is to allow its creator to discretely update their Will as they wish, and to allow other users to check to see if they have the most up-to-date version of the Will. Instead of storing the entire Will publicly as text on the blockchain, this contract hashes the text of the Will and stores the hash on the blockchain. It is a very simple contract. The smart contract can be found here and at the end of this tutorial.
Initial Installation and Setup for the Ethereum Wallet
This tutorial was developed on the #ethereum_study_group channel on the Slock.it Slack (click to request an invite) if you have any questions or complications, that is the best place to ask for help!
Download the Ethereum Wallet, this tutorial was written for the 0.3.9 version on a 64-bit Windows OS, but it works just as well on the newer versions of the Ethereum Wallet. Note that any shortcuts that you have on your desktop from previous installs will still bring you back to that older version.
Extract the zip file and run the Ethereum-Wallet file. Allow time for the browser to sync to the blockchain. Depending on your internet connection, this whole process could take one hour or ten hours.
NOTE: If you are trying to run this on something besides a 64-bit Windows OS, you will likely have to add a few steps after this one to get to the next step; I strongly suggest finding a 64-bit Windows computer to do this tutorial, but if you are crafty, you can make it work on other OS’s.
Input a Password. The Ethereum Wallet will ask you to make a password for your Etherbase Account (your main account). They recommend a strong password. If you are not going to store real ether on this account I recommend an easy password as you will have to type it many times. After you see how incredible Ethereum is, you will probably want to make a new account with a strong password and go get some ether, but for now, keep it simple.
Work in the Testnet. Since this is just a fun learning exercise, once the wallet starts up go to Develop > Network > Testnet (Morden). This will now require you to download the Testnet Ethereum blockchain. This blockchain is used for testing purposes since it is the exact same as the Ethereum blockchain, except it uses a coin that has no value.
Get Testnet ether by mining or from a faucet. In the crypto world, you need to have currency to interact with the blockchain so you have 2 choices:
You can either mine Testnet ether, which is really easy and will help make your contract load quickly. See @avsa’s blog post for instructions on how to do that.
You can use this faucet and get yourself some Testnet ether generously donated by the community. Your public addresses can be found by going to WALLET and clicking the Etherbase Account icon. The address is displayed under the account name at the top and starts with “0x”. Every time you load the webpage with your address in the URL you will get sent some Testnet ether (it will appear in your account once the next block gets confirmed).
Now you have the Ethereum Wallet loaded with Testnet ether and you can begin to use the Will Manager smart contract.
Deploying the WillManager.sol Smart Contract to the Blockchain
If you were truly desiring to mange your Will using this smart contract the first step would be of course to write your Will. Since this is just a tutorial, you can skip this and create your Will on the spot. For example, “Everything gets buried with me!” or my favorite “asdf”.
Go back to the Ethereum Wallet and go to CONTRACTS and DEPLOY NEW CONTRACT
Paste in the code from the WillManager.sol contract which is found at the end of this tutorial and in my GitHub. Delete the default code in the text box first then paste it in. The most common error here is extra text pasted into the text box either at the top or at the bottom of the contract. Often the Wallet will tell you where the error is; “Error: :50:1” means there is an error on line 50 at character 1.
Read over the WillManager.sol code. It is easy to understand and if you can understand how this code is being used when you are interacting with the wallet you will learn so much more.
Click “Pick a contract”, select “Will Manager” then scroll down and click “Deploy.” This selection will appear to the right of the text box.
Type in your password. A window will pop up asking for the password to the account that is deploying the contract.
Navigate to the “Will Manager ####” contract. You will be automatically transported to “Wallet Overview” and once the next block has been found, a contract called “Will Manager ####” will appear in your transaction, click that text.
Click “Pick A Function” and select “New Will.” It is on the right, under “Write to contract.” This is the area that allows you to interact with the contract and the blockchain. To the left under “Read From contract” there are variables from the contract on display. The only one with a value from the beginning is “Will owner” which will match the account address that called the smart contract.
Type out your Will in the box that appears under “Will — string” (in this case the text of the will is simply asdf) and click “Execute”. A pop-up will appear; put in your password and click “Send Transaction”.
Notice the change, your Will is now submitted to the blockchain. When the next block is found, the “Hash of will” will appear on the left (It’s the sha3 hash of the Will with 0x added to the beginning) and “Will created” will say Yes.
Send the Will to your friends so they can check it. If this program was truly being implemented, at this point the writer of the Will would want to email all of their chosen verifiers of their Will 3 things:
A .txt file of just the Will that was hashed into the blockchain (I say a .txt file to avoid a copy-paste error that might add extra content to the Will; extra or missing content would make the Will hash to a different value and not match).
The Ethereum address to the contract listed on the top of that page under WILL MANAGER #### (Starts with “0x”).
The JSON Interface for the contract that can be found by clicking the “Show Interface” icon to the right above “Write to contract”.
Your friends would need to get the Ethereum Wallet and add your “Will Manager ####” contract to it. The recipient of this information (effectively one of the executors of the estate) would download the Ethereum Wallet and follow the same steps above, but instead of deploying a new contract in step 9, they would click the WATCH CONTRACT icon and use the information from the previous step to find this contract on the blockchain and use the text in the simple .txt file to verify the Will. If you have a friend to help you try this out, it is something worth practicing; it can be a little tricky.
Set up a new account to test the contract works on your own. If you just want to create a second account to test the contract, go to WALLET and click the ADD ACCOUNT icon, after typing a new password twice ACCOUNT 2 will appear, click the icon for your new account. Then on this screen you can rename your account and copy your account’s address (starts with “0x”). Then use your Etherbase account to send some Testnet ether to it.
Verify the Will with the new account. Now go back to CONTRACTS and get back into your Will Manager contract. Call the “Check Will” function as one of the verifiers of the Will would. Enter the text of Will if its not already there, use the “Execute From” drop down to select your second account, and click “Execute”, and type in your password to that account. Again when the next block comes, the area to the left will change, but this time “Will is correct” will change to “Yes”, “Hash of will being checked” will have the hash added, and “Last will checker” will have the address that was used to check the Will. You will notice that the “Will Owner” and the “Last will checker” are different, and the “Hash of will being checked” and “Hash of will” are the same.
Test the contract and notice the changes that occur. Feel free to play around by selecting “New Will” and “Check Will” and using different accounts to execute the function. Change the Will to something else when executing the function. You will see that the values to the left will vary accordingly. If an account that did not originally deploy the contract tries to call the “New Will” function, “Will created” will become “No” and The “Hash of will” will not change. If a user tries to verify a Will that doesn’t match the most current version of the Will then “Will is correct” will become “No” and the “Hash of will being checked” will not match the “Hash of will”.