Posts

Showing posts with the label solidity programming language

How to use enum in Solidity programming langauge ?

How to use enum in Solidity programming langauge ? pragma solidity ^0.5.0; contract test {    enum FreshJuiceSize{ SMALL, MEDIUM, LARGE }    FreshJuiceSize choice;    FreshJuiceSize constant defaultChoice = FreshJuiceSize.MEDIUM;    function setLarge() public {       choice = FreshJuiceSize.LARGE;    }    function getChoice() public view returns (FreshJuiceSize) {       return choice;    }    function getDefaultChoice() public pure returns (uint) {       return uint(defaultChoice);    } }

How to use arrays in Solidity programming language ?

How to use arrays in Solidity programming language ?  How to use arrays i.e  static array,dynamic array  in Solidity programming language   pragma solidity ^0.5.0; contract test {    function testArray() public pure{       uint len = 7;               //dynamic array       uint[] memory a = new uint[](7);              //bytes is same as byte[]       bytes memory b = new bytes(len);              assert(a.length == 7);       assert(b.length == len);              //access array variable       a[6] = 8;              //test array variable       assert(a[6] == 8);              //static array       uint[3] memory c = [uint(1) , 2, 3];   ...

How to use Local Variable for whose values are present till function is executing in solidity ?

  How to use Local Variable for whose values are present till function is executing in solidity ? pragma solidity ^0.5.0; contract SolidityTest {    uint storedData; // State variable    constructor() public  {       storedData = 10;       }    function getResult() public view returns(uint) {       uint a = 1; // local variable       uint b = 2;       uint result = a + b;       return result; //access the local variable    } }

How to use state Variable for stored values permanently in a contract storage in solidity ?

  How to use state Variable for stored values permanently in a contract storage in solidity ? pragma solidity ^0.5.0; contract SolidityTest {    uint storedData;      // State variable    constructor() public  {       storedData = 10;   // Using State variable    } }

How to use comments in Solidity programming language ?

 How to use comments in Solidity programming language ?  function getResult() public view returns(uint) {    // This is a comment. It is similar to comments in C++    /*       * This is a multi-line comment in solidity       * It is very similar to comments in C Programming    */    uint a = 1;    uint b = 2;    uint result = a + b;    return result; }

Write your first Application in Remix IDE to Compile and Run our Solidity programming language ?

 Write your first Application in Remix IDE to Compile and Run our Solidity programming language ? pragma solidity ^0.5.0; contract SolidityTest {    constructor() public{    }    function getResult() public view returns(uint){       uint a = 1;       uint b = 2;       uint result = a + b;       return result;    } }

What is the use of Pragmas keyword in solidity programming language ?

 What is the use of Pragmas keyword in solidity programming language ? The pragma keyword is used to enable certain compiler features or checks.  A pragma directive is always local to a source file, so you have to add the pragma to all your files if you want to enable it in your whole project.  If you import another file, the pragma from that file does not automatically apply to the importing file.

All 35 reserved keywords in Solidity programming language

All 35 reserved keywords in Solidity programming language       1. abstract 2. after 3. alias 4. apply 5. auto 6. case 7. catch 8. copyof 9. default 10. define 11. final 12. immutable 13. implements 14. in 15. inline 16. let 17. macro 18. match 19. mutable 20. null 21. of 22. override 23. partial 24. promise 25. reference 26. relocatable 27. sealed 28. sizeof 29. static 30. supports 31. switch 32. try 33. typedef 34. typeof 35. unchecked

what is solidity programming language ?

What is solidity programming language ?  Solidity is a contract-oriented, high-level programming language for implementing smart contracts. Solidity is highly influenced by C++, Python and JavaScript and has been designed to target the Ethereum Virtual Machine (EVM). Solidity is statically typed, supports inheritance, libraries and complex user-defined types programming language. You can use Solidity to create contracts for uses such as voting, crowdfunding, blind auctions, and multi-signature wallets. When deploying contracts, you should use the latest released version of Solidity. Apart from exceptional cases, only the latest version receives security fixes. Furthermore, breaking changes as well as new features are introduced regularly. We currently use a 0.y.z version number to indicate this fast pace of change. A Simple Smart Contract example  // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.4.16 <0.9.0; contract SimpleStorage {     uint storedData; ...