Infernal_Toast's Learn About Solidity 101 - Happy Fun Time


#1

This guide assumes you already know the basics about the Ethereum Network and how to use Metamask from a general perspective.

Ethereum allows anyone to pay a small fee of Ether in order to publish a snippet of code on the Ethereum Blockchain where it will reside permanently. This code can store data, read data, and manipulate data and it uses a turing complete machine language so it is very powerful. The code cannot be used to query traditional HTTP networks or clearnet APIs so input data typically consists of chain data or data which has been injected by Oracles (more on that later.)

One of the most popular and time-tested programming languages for Ethereum is called ‘Solidity’. The Solidity Docs are here. please become familiar with them: http://solidity.readthedocs.io/en/v0.4.24/

Solidity is similar to javascript though it is much more restricted (simpler) and has very specific data types: https://solidity.readthedocs.io/en/v0.3.1/types.html (read that!)

Here is an example of a solidity contract, please read this:
http://solidity.readthedocs.io/en/v0.4.24/solidity-by-example.html

Here is another good contract to familiarize yourself with: the standard ERC20 contract:

Notice how this contract imports two other contracts. That way, like a ‘class’, the contract can extend those two classes and inherit all of their methods and variables! This makes solidity very modular.

Another favorite contract of mine is the Cryptopunks contract:

Reading through lots of contracts can actually teach you quite a bit about solidity. Playing with them makes you even better. This is the next step. To play with contracts, I recommend you download truffle here: https://github.com/trufflesuite/truffle

truffle-logo

It is easiest to download truffle on linux (you are developing on Linux right?) using NPM with ‘npm install -g truffle’. Follow the truffle tutorial (unboxing) : http://truffleframework.com/docs/getting_started/project

To test-deploy contracts you you will need some ropsten test ether. Try to get some here: http://faucet.ropsten.be:3001/

Make sure you have Metamask installed in chrome and sign in. Now visit Ethereum Remix to publish some solidity to Ropsten Test Net: https://remix.ethereum.org/

Click on ‘Start to Compile’ on the right side when you are happy with the code on the left. Once this completes, click on the ‘Run’ tab, set Environment to Injected Web3, select the account from Metamask, and select the name of your contract from the dropdown and click the red Deploy button.

A metamask prompt will appear so accept this. Now wait and monitor the Remix Console at the bottom and when the TX is mined you will be able to interact with it on the blockchain!! Congrats !