Ethereum & Solidity

Ethereum and Solidity Course Notes


Last Updated: March 01, 2024 by Pepe Sandoval



Want to show support?

If you find the information in this page useful and want to show your support, you can make a donation

Use PayPal

This will help me create more stuff and fix the existent content...


Ethereum Intro

  • When we work with Ethereum we work with a network of computers
  • Ethereum networks are used to transfer money and to store data
  • There is ONE main ethereum network but there are many eth networks. i.e.: testing networks and private networks
  • Networks are formed by one or more nodes
    • An Eth node is a computer running and ethereum client
    • Each node on the network has a full and separate copy of the blockchain
  • You can think of the blockchain as a database that stores a record of every transaction that has ever taken place and also stores data

Network

  • An external account consists of 3 pieces:

    • Address: shareable unique identifier that identifies your account
    • Public & Private Key: together form a sort of password used to auth sending of funds to other accounts
  • An external account are the ones owned by an user and can be used across all different eth networks, same account can connect to main network and to testing network (i.e.: Sepolia)

  • When connected to a network if you have tokens on that network other networks dont have a way to know this

  • web3 library used to interact with any ehtereum network

  • Transaction: it is record/object that describes the transfer of funds from one account to another

  • Users create transaction objects which are then sent to the ETH network to be processed, then we need to wait gor a transaction to be confirmed

Transaction

  • vrs : generated by the senders private key, you can generate vrs with the private key but if you have vrs you cannot generate the private key, they can be used to calculate/generate the sender's address

  • trasaction are actually send to a particular node

  • A block is a set of trandactions that will be processed by a node and added to the blockchain if it passes a validation

  • Minning The process of a node runnign calculations on a block to validate it

  • Signed block has a hash that is less that a certain target value (totally arbitrary), simplistically a hash that starts with 4 zeros

Transaction flow

  • Hash: finger print or unique ID of data with a fixed length

  • Hash is a 256 Bits -> 64 Characters value which means range is from 0 -> 2^256 = 1.1579209e+77

  • mining: you have 64 dices wach with 16 faces you roll the dices and incremrent the nonce until you get a number less than certain value

  • Block Time Time that it takes to hash everything from zero to the time we find a nonce that produces a hash that is less than a target value

    • Once a eth node find a solution it has to distribute solution to other nodes
    • The Ethereum network has a target block time of 15 seconds (on ideal world it will only take 15s to calculate a block) but in reality this is variable
    • Target value is adjustable every block (higher target -> more likely to find ; lower target -> less likely to find) to meet actual computing availability
    • https://etherscan.io/chart/blocktime chart that shows you the average amount of time that has taken to calculate blocks over the last two years

Smart Contract

  • Smart Contract is an account with extra info that is controlled by code and instructs the contract how to behave

  • Smart Contract properties:

    • Balance: amoutn eth controlled by this account
    • Storage: field to store some data related to the contract
    • Code: raw machine code (compiled code) for this contract
  • Contract accounts are only specific to one individual network

  • devs create contract source, this is then compiled and deployed to a network which creates an instance of the contract (Contract account)

References and Sources

Want to show support?

If you find the information in this page useful and want to show your support, you can make a donation

Use PayPal

This will help me create more stuff and fix the existent content...