Solidity is a high level programming language that we can use to create smart contracts in ethereum, solidity as a language was design to target the EVM machine. The contracts that can be created are applications, machine code, that will running on ethereum blockchain. Examples of such contracts could be a voting mechanism, an auction, a currency and also many other ideas can be applicable there.
If you are already using nodejs, the solidity compiler can be installed easily through its packaging system. In a linux environment with nodejs and npm, the installation of solidity compiler can be done through command line by using the following command.
sudo npm install -g solc
To check if the command line utility and the compiler was installed successfully we press
Let's create a file with name first_contract.sol then there are plenty code of samples to test, let's choose the remote purchase paste the code file you find in the previous link in the file we just created then we have to compile the contract using this command
solcjs --bin --abi first_contract.sol
the previous command will output two files the first one has extension .bin is the contract compiled code (bytecode) that we will use in ethereum client to deploy the contract. The other file with file extension .abi is the application binary interface and describes how a user will interact with the contract.
There are a lot of applications that can be created, the previous example we provided a link with the code for a remote purchase do not use it in real life only to study the code, there is flaw if the buyer goes rogue and doesn't confirm that he received the product the etheur will not be released to the seller.
Initial Coin Offer (ICO)
One of the most notable applications that somebody can create with smart contracts are the ICOs, initial coin offer. It's a form of crowdfunding that you are able to collect funds for a project by selling rights of ownership. The fundamental difference between this and classic crowdfunding campaign, that run by websitew like indiegogo, is that the backers control the release of the money and also could take decisions through with mechanisms.A library for writing secure contracts such as various kinds of ICOs is OpenZeppelin.
In the previous sections we saw how to compile simple a smart contract, but to learn solidity programming there is cryptozombies for interactive lessons in solidity programming