Monday, August 21, 2017

Ethereum Solidity

Solidity is a contract-oriented, high-level programming language for writing smart contracts which run on Ethereum Virtual Machine. Solidity language is statically typed and follows object-oriented principles.  It supports inheritance, libraries and complex user-defined types. Solidity’s syntax is similar to that of ECMA Script (JavaScript) syntax making it familiar for existing web developers.

Here is the Hello World solidity code we looked earlier.
pragma solidity ^0.4.14;

contract HelloWorld {

    function greet() public constant returns (string) {
        return "Hello World!";

Solidity code is compiled to bytecode that is executable on the EVM. We can use solc, the solidity compiler, or developer editors such as Visual Studio Code to compile and generate the bytecode. Here is the bytecode for the above Hello World sample.


Solidity also uses an application binary interface (ABI). ABI defines the structure and methods used in the contract. Ethereum internally uses ABI for encoding and decoding data into and out of transactions. We can use this ABI during contract deploying and also to decode the data passed with transactions. Here is the ABI for our Hello World code.


No comments:

Post a Comment