Contract Programming Key Terms 🔥

#### ETH
ETH is the main currency on the Ethereum network. However, Ethereum can support multiple currencies and ETH eventually will not have privileged status.

Gas

Executing transactions on Ethereum either runs computations or stores data. This Costs the network CPU cycles or storage space. That cost is paid for by the account that initiates the transaction. The payment is called "gas". Gas is currently paid using ETH. At the time of writing this, 1 GAS = 0.00001 ETH.

Morden

Morden is a name for one of the most popular public Ethereum TestNets. It is the same as the Ethereum network, but ETH on Morden is worth nothing. You can get ETH for free on Morden from many Morden "ETH faucets".

Setting up Metamask 🚀

To easily deploy contracts to Morden, we will need Metamask. First install Metamask if you haven't already here.

In the top right corner of Chrome you should now see the cute Metamask fox :)

Click on the icon and let's start creating your Ethereum wallet!

Agree to the terms of service. At the time of writing this, Metamask is beta software, so if you want to use it for the MainNet, just don't store or transact more than you can lose.

Now click CREATE NEW VAULT. This will begin the wallet generation process.

Input a password.

Note: If you want to use this account for anything of value, use a unique randomly generated password stored in a password manager like 1Password or LastPass.

Back up your randomly generated "seed phrase". This is your master password for the vault. Keep it extremely secure, and definitely don't post it on the internet.

Fun Fact: Your account information is never sent to anyone on the network. It's never registered in some database. Instead, we rely on the probability of two people generating the same account being so low that it's nearly impossible. However, it could happen to you! (Though it will almost certainly not)

Congratulations! You now have an Ethereum wallet. In the top left corner, you should see "Morden Test Net". This is the network you are currently connected to. You can click it and switch between TestNets and the MainNet. We are going to stay on the Morden TestNet.

Before uploading our contract, we will get a little extra ETH just in case. To do this, click "BUY".

You will be taken to the MetaMask ether faucet where you can click "request 1 ether" and it should send it to your account. If you ever run out of ETH, just come back here

Time to write our first contract! ✏️

MetaMask is pretty much set up. Now we've got to use it! First, go to this website:

This is a good browser-based Solidity editor. It allows you to deploy contracts and interact with contracts. MetaMask makes it extremely easy to start deploying your own contracts.

Once you visit the site, you will see an example contract. Just ignore it--it's quite complex. Instead, click on the box icon. (Browser Solidity is not very intuitive, so it's natural to be a bit confused at first)

Make sure that Injected Web3 is selected. If it is, then Browser Solidity recognized that you're using MetaMask and it will connect to their servers. If it is not selected, make sure MetaMask is running and refresh the webpage.

Next, let's take a look at the HelloWorld contract we are going to deploy to the network:

What's an event? Events are essentially logs in the EVM. When running a contract, you can call events and pass them the data you wish to log. In this case, we create a custom event called log_string(bytes32 log). This will log whatever we pass in as a parameter. More information here

What's function () {}? This is a fallback function. Fallback functions are special functions which are called when a contract is called and no existing function was specified. Fallback functions are commonly used as they are executed whenever a user sends ETH to a contract, and that's why we are using it.

How will this work? We will deploy this contract to the TestNet. Once we have done that, we will send a transaction to the contract. We will then use an Ethereum block explorer to read the log.