cryptoizotx avatar

Decentralized Programmer: Solidity 101

cryptoizotx

Published: 25 Oct 2018 › Updated: 25 Oct 2018Decentralized Programmer: Solidity 101

Decentralized Programmer: Solidity 101

Solidity primer

What is solidity?

Solidity is a contract-oriented, high-level language for implementing smart contracts. It was influenced by C++, Python and JavaScript and is designed to target the Ethereum Virtual Machine (EVM). Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

Source: https://solidity.readthedocs.io/en/v0.4.25/

Best IDE

Remix: http://remix.ethereum.org

Smart contracts basics

pragma solidity ^0.4.0; //Version of solidity

contract SimpleStorage {
    uint storedData;

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

Explanation:

pragma solidity ^0.4.0 Version of solidity

contract SimpleStorage Contract is a collection of code, functions and data. Contract resides on a specific address on Ethereum blockchain

uint storedData Unsigned Integer that represents some data.

    function set(uint x) public {
        storedData = x;
    }

    function get() public view returns (uint) {
        return storedData;
    }
}

Getters and setters. What's interesting the visibility of the function is declared after the list of arguments. The keyword view indicates that method get() won't modify the state of the contract.

Leave Decentralized Programmer: Solidity 101 to:

Written by

Crypto Trader / Software Engineer

Read more #solidity posts


Best Posts From cryptoizotx

We have not curated any of cryptoizotx's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From cryptoizotx