Solidity

By on

What is Solidity?

  • Contract-oriented high-level programming language
    • Syntax is similar to JavaScript and C#
    • Contracts and inheritance similar to OOP
    • Libraries

Contracts

  • Contract in Solidity are like classes in OOP programming
  • Contracts can hold:
    • Data and functions
  • Contract execution is paid with gas (Bus Analogy)
  • Contract is compiled by the solidity compiler

Mapping in Solidity

Application Binary Interface (ABI)

  • Describes the contract’s interface
    • Public methods
    • Inputs
    • Return values
    • Events

Gas

  • Gas is the internal unit for keeping track of execution costs Ethereum
  • Gas cost measures the consumed computational resources Ethereum
    • Each CPU instruction in EVM costs gas
    • Each persistent storage write also costs gas
    • Ex. Writing 32 bytes into a contract memory costs 80000 gas
  • Gas price is how much someone is willing to pay per unit of Gas Cost Ethereum

Gas cost vs Gas price

  • If you are driving to California from Arizona, you would always have the same gas cost (how many miles), however you would probably pay a different “gas price” for this depending on the supply/demand etc etc
  • Gas price is how much someone is willing to pay per unit of Gas Cost Ethereum