Deploy your first smart contract

Deploy your first smart contract

Day 1 of learning how to build smart contracts with solidity remix Ide

This will be a really short tutorial on how to deploy your first smart contract, this will tutorial will come in series of other tutorials on solidity i will be writing about as i learn more.

My Story

Recently there have been demand for blockchain developers globally and i think these demand will continue to increase, as a full stack developer from the web2 space i decided to join this train before it reach it full potential so if you dont want to be left behind you can as well follow me as i embark on this journey.

What is a Smart Contract?

This is just a set of functions declared inside a Contract that is been executed when the contract is been deployed to the blockchain.

Lets show some example for more clarity

contract Storage {

    uint256 number;

    /**
     * @dev Store value in variable
     * @param num value to store
     */
    function store(uint256 num) public {
        number = num;
    }

    /**
     * @dev Return value 
     * @return value of 'number'
     */
    function retrieve() public view returns (uint256){
        return number;
    }
}

Here is a basic Storage Contract in solidity that executes store function and the retrieve function when it is deployed to the blockchain.

I wont be covering the implementation details inside each function in this tutorial the example above is just to make you understand the buzz word smart contract that is common in the web3 space.

##How do you write your own smart contract you can deploy?

Well for beginners level i will advise you use Remix Ide this online Ide will get you up and running in no time without you having to manually configure your server check out there docs for more info.

To write your first smart contract with remix Ide create a file in the contracts folder provided for you already and create a file named HelloWorld.sol which is the standard for naming files in solidity.

// SPDX-License-Identifier:GPL-3.0;

pragma solidity >=0.7.0;

contract HelloWorld{

    string public test ="hello from test network again";
}

The first two line of code of the snippet above are standards for writing solidity smart contracts you have to include the license and also the version of solidity your code is compactible with, the second line makes sure your code does not run when a different version of solidity is used to run your code.

Inside the contract HelloWorld you declare your variable just like any other language, you first declare the data type of the variable you want to save after that you make the variable public so it can be accesible outside the blockchain and lastly you give your variable a name then you set the value to a string or any data type you initialized.

compile your smart contract with ctrl save on windows then deploy your smart to a local blockchain sort of if their are no errors you should see your contract been deployed mostly on the left pane of the editor click on it you should see your variable and the valued assigned to it.

Viola if you get to this stage you succesfully deployed your first smart contract using remix Ide congratulations.

This might not be the most technical tutorial but its a step to you achieving greater things, stay tuned as i learn and share my journey on blockchain technology with you.