let’s learn about solidity lesson 1

anish jain
2 min readNov 16, 2021

--

Date : 16–11–2021

it’s is language we used to write “smart contract” which is similar to the c++ and JS you get the point so having basic knowledge of c++ is good

smart contract ” what the hack is that just think them as small piece of code which you can write into ETH blockchain and which is there forever you can’t change it because that’s immutable guys

This smart contract makes ETH so powerful because Now you can run your code into ETH Blockchain network and make Blockchain based apps quite complex app.

Fundamentals of Solidity

Datatypes:

  • Uint256 “as name suggested for integer”
  • String
  • so on…..

How to make new kind of datatypes

use struct keyword for ex


struct Person{
uint256 id;
string name;
uint256 age;
}
syntax for defining variable data type "visibility type "name; // default value for "state variable" is 0ex
uint256 public number;
String public name = "anish";

now what it visibility: is use for — who calls what

  • public — anyone can call it
  • internal — only internal function can call them
  • external — only be called from third party not inside from our own “Contract
  • private — only be called from main contract

Use Remix IDE for fast leaning
https://remix.ethereum.org/

pragma solidity 0.8.7;contract Learn{
// Variable_type visibility name
uint256 number;
struct Person{
uint256 id;
string name;
uint256 age;
}

Person public p1 = Person({id:1,name:"ansih jain",age:21});

Person[] public people;

function addNumber (uint256 _number) public {
number = _number;
}

function getNumber() public view returns(uint256){
return (number);
}

function addPerson(string memory _name, uint256 _age, uint256 _id) public {
people.push(Person({name:_name, age:_age, id: _id}));

}

}

so when you look into above code any variable which is not inside a function is called state variable

view ”is just again a keyword used to tell this function is for viewing / returning stuff

Hope this above code helps you but still anything is not clear let me in comments and I will try to answer them

I just start learning Blockchain hope you guys also get started “Lets build the community guys ”

Best regards

Anish

--

--

anish jain

like to create things,and some time to break them to get indepth knowledge,stronly believe in learning never exhaust the mind