The last post I listed some important bullet points I considered important to start the path to learn Ethereum and concepts around that theme.

Ethereum is an application of the blockchain such as bitcoin. The cryptocurrency to allow transactions in the ethereum network is the ETHER (ETH). The incentive to verify or execute the transactions is the payment of a fee, the gas, a fraction of ETH. The transactions are verified by the nodes.

The interaction with ethereum can happen through the DAPPs, (decentralized application) which combine smart contracts and frontend user interfaces. The executions are done inside the EVM (Ethereum Virtual Machine). The dapps can interact with a library in JavaScript web3.

What is

A "smart contract" is simply a program that runs on the Ethereum blockchain. It's a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain.

The idea is to have a contract between two or more parts that allow the parts to transact directly with each other. That contract has rules which parts agree to execute. The contract is the law. No one has the control and is not necessary a third part. The contracts are distributed and the outcome is validated by networks.

That program has life in blockchain. After created and commited to the blockchain the contract cannot be changed anymore. It makes the contracts immutable. If exist same error with the contract is necessary to create another one with the fix and redirect your application to the new contract. The code is executed in the EVM.

The only possibility that code is removed from the blockchain is when a contract at that address performs the selfdestruct operation. The remaining Ether stored at that address is sent to a designated target and then the storage and code is removed from the state. [Self-destruct]

The most popular languages to create a contract are Solidity and Vyper. The first one is the most popular. The languages to create dapps can be Java, Go, JavaScript, .NET, Python, Rust.

Stack: Smart Contract (your program to execute on blockchain), EVM (runtime environment for smart contracts), Node (do the communication between the dapp and the network), APIs (allow user applications to connect/communicate with the Ethereum blockchain/Node.), End User App (Web/Mobile).

Advantages: Autonomy, Trust, Backup, Safety, Speed

Beginning...

If you want to start to understand how to create one contract in a funny way without any dependencies you can start by Cryptozombies, where you will start open your mind to the coding.

To create your first smart contract you can use the online IDE Remix. As well, you need the Metamask plugin to create accounts to simulate the transactions, ganache to simulate blockchain and test your development. Finally, web3.js allows your web app to use your contract.

Here is a simple example.

pragma solidity >=0.5.0 <0.6.0;

contract MyFirstContract {

    event NewEntity(uint id, string name, uint value);

    struct Type {
        string name;
        uint value;
    }

    Entity[] public entities;

    function _createEntity(string memory _name, uint _value) private {
        uint id = entities.push(Entities(_name, _value)) - 1;
        emit NewEntity(id, _name, _value);
    }

    function createRandomEntity(string memory _name) public {
        uint randValue = uint(keccak256(abi.encodePacked(_name))) % 16;
        _createEntity(_name, randValue);
    }
}

Here one abstraction of the line where the JS could call the contract:

var MyFirstContract = web3.eth.contract(YYYYYYYYYY)
var contractAddress = XXXXXXXXXXX
var myFirstContract = MyFirstContract.at(contractAddress)
myFirstContract.createRandomEntity("TEST");

Next post I'll describe a complete use case.

References