Solidity Steps
  • Learning Solidity
  • Step 1
    • 1: Introduction
    • 2: Data Types
    • 3: Functions
    • 4: Control Structures
    • 5: State Variable
    • 6: Local Variables
    • 7: Global Variables
    • 8: View Keyword
    • 9: Pure Keyword
  • STEP 2
    • 10: Immunable Keyword
    • 11: Events
    • 12: Condition
    • 13: While Loop
    • 14: Do While Loop
    • 15: For Loop
    • 16: Required
    • 17: Assert
    • 18: Revert
    • 19: Modifier
  • STEP 3
    • 20: Constructor
    • 21: Mapping
    • 22: Array
    • 23: Enum
    • 24: Structs
    • 25: Data Location
    • 26: Inheritance
    • 27: The Shadowing Effect
    • 28: Super Keyword
    • 29: Visibility
  • STEP 4
    • 30: Interface
    • 31: Abstract Contract
    • 32: Payable
    • 33: Using type()
    • 34: Sending Ether
    • 35: Receive
    • 36: Fallback
    • 37: Call
    • 38: DelegateCall
    • 39: Calling Other Contracts
  • STEP 5
    • 40: Factory Contract
    • 41: Proxy Contract
    • 42: Create2
    • 43: Try and Catch
    • 44: Solidity Library
    • 45: ABI Encoded
    • 46: ABI Decoded
    • 47: Keccak256
    • 48: Function Signature Hash
  • TIPS
    • Tips: Solidity by "Immunable"
    • Tips: Truffle Tutorial
    • Tips: Microblog Dapp
    • Tips: Reentrancy
    • Tips: Slither Tutorial
    • Tips: Remix Tutorial
    • Tips: Hardhat Tutorial
  • CAREER
    • 💲Cover Letter
    • 💲Resume
  • ABOUT
    • Contact me
Powered by GitBook
On this page
  • Lesson 1: Introduction to Solidity
  • Let's break down the code:
  1. Step 1

1: Introduction

Introduction to Solidity

Lesson 1: Introduction to Solidity

Solidity is a contract-oriented programming language used for developing smart contracts on the Ethereum blockchain. Smart contracts are self-executing contracts with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist on a decentralized blockchain network. This makes smart contracts immutable, transparent, and autonomous.

A smart contract is essentially a piece of code that runs on the Ethereum blockchain. The code can interact with other smart contracts and with the Ethereum network as a whole. Smart contracts can be used to automate the transfer of funds, to manage complex workflows, and to enforce business rules.

Here is an example of a simple smart contract written in Solidity:

pragma solidity ^0.8.0;
 contract MyContract { 
    string public message; 

    function setMessage(string memory newMessage) public { 
        message = newMessage; 
    } 

    function getMessage() public view returns (string memory) { 
        return message; 
    } 
}

This contract is a simple storage contract that allows you to store a message on the Ethereum blockchain. The setMessage function allows you to set the message, and the getMessage function allows you to retrieve the message.

Let's break down the code:

  • The first line (pragma solidity ^0.8.0;) specifies the version of Solidity that the code is written in. In this case, we're using version 0.8.0 of Solidity.

  • The contract MyContract line defines a new contract called MyContract.

  • The string public message line defines a public state variable called message, which is a string.

  • The setMessage function takes a string parameter called newMessage, and sets the value of the message state variable to the new message.

  • The getMessage function is a read-only function that returns the value of the message state variable.


That's it for the first lesson! In the next lesson, we'll go over data types in Solidity.

PreviousLearning SolidityNext2: Data Types

Last updated 2 years ago