Reach Markets

Ethereum: Fundamentals of solidity

As a developer, Building Blockchain, understanding the foundations of solidity is crucial. In this article, we will immerse ourselves in the basic concepts of the solidity programming language used for Ethereum’s intelligent contracts.

What is solidity?

Ethereum: Solidity fundamentals

Solide is a programming language specially designed to write intelligent contracts in Ethereum Blockchain. It is an open source language that is based on the C ++ language with additional characteristics and constructions adapted to the development of blockchain.

Key concepts of solidity

Before immersing ourselves on specific issues, we cover some fundamental concepts:

* Variables : The variables are used to store the data in a contract.

* Functions : The functions are reusable code blocks that perform a specific task. In Ethereum contracts, the functions are the constituent elements of a complex logic.

* Events : events are triggered by specific actions in a contract and can be used to inform other parts of the changes in the state of the contract.

Basic solidity syntax

Here is an example of basic solidity syntax:

`Solidity

Pragma solidity ^ 0.6.0;

Mycontract contract {

Uint Myvariable Public;

function affirmed Lessssfromdge (

Bytes calldata message,

BYTES COLLDATA CERTIFIED

) public {

// Comment: This is a comment in Solidey, not in the code.

// To write code, use the keyword "function" and define the variables or functions here.

}

}

'

In this example:

  • Pragma solidity ^ 0.6.0;It is a pragma directive that specifies the version of the solidity used.

  • Mycontract contract {…}defines the scope of the contract.

  • It is not myvariable public;declares and initializes a variable with the type 'uint ”.

  • RE DELEASE FUNCTIONSFROMRIDGE (Bytes Calldata Message, Certified Calldata Bytes)It is an event function that takes the 'message' and 'attestation' parameters.

Variables

In solidity, the variables are declared using the keyword "var":

Solidity

Pragma solidity ^ 0.6.0;

Mycontract contract {

Uint Myvariable Public;

Builder () Public {

// Comment: This is a comment in Solidey, not in the code.

// To write code, use the keyword "manufacturer".

Myvarious = 10; // Initialize the variable with an initial value

}

}

'

The variables can be declared within a function, a class or a module.

Functions

The solidity functions are defined using the keyword "function":

Solidity

Pragma solidity ^ 0.6.0;

Mycontract contract {

Uint Myvariable Public;

function affected Lessssfrombridge (

Bytes calldata message,

BYTES COLLDATA CERTIFIED

) public {

// Comment: This is a comment in Solidey, not in the code.

// To write code, use the keyword "function" and define the variables or functions here.

Myvarious = 20; // Update the value of the variable

}

}

'

Functions can take entry parameters of any kind, including "bytes", "uint", "address", etc.

Events

In solidity, events are triggered by specific actions in a contract. The events can be used to inform other parts of the contract declaration:

Solidity

Pragma solidity ^ 0.6.0;

Mycontract contract {

Uint Myvariable Public;

The event said that

Direction of the indexed sender,

Uint256 quantity of the quantity

));

function affected Lessssfrombridge (

Bytes calldata message,

BYTES COLLDATA CERTIFIED

) public {

// Comment: This is a comment in Solidey, not in the code.

// To write code, use the keyword "event" and define an event here.

Emi said that lesassfrombridge (msg.sender, 10); // Activate an event with a message

}

}

` ‘

The events can be broadcast using the keyword “emit”.

ethereum json bitcoind

Leave a Reply

Your email address will not be published. Required fields are marked *