Cover photo

Udemy-Ethereum and Solidity-Section 1 Notes

While browsing crypto experts’ LinkedIn profiles, I found this course👇

https://www.udemy.com/course/ethereum-and-solidity-the-complete-developers-guide/

This course aims to teach you how to build web apps with Ethereum. I’m not a geek and haven’t even built a website or app before, but learning some underlying technologies of Web3 can help me better understand this ecosystem.

It's important to review what you've learned in stages, so I’ll take some notes whenever I finish a section. Here are the notes from Section One.

History

  • 2018.10.31 Bitcoin was born, a peer-to-peer electronic cash system

  • The most important part of the Ethereum network: SMART CONTRACT(a piece of code that lives in the Ethereum blockchain)

What is Ethereum

Working with Ethereum = Working with a network of computers

There are many different Ethereum networks:

  1. one main Ethereum networks

  2. test networks-solely for testing code & transactions

  • Networks are formed by one or more nodes(a node is a machine that runs an Ethereum client)

  • Anyone can run a node

  • Each node we create has a full & separate copy of the blockchain

Interfacing with Ethereum networks

For developers: web3.js (portal into the Ethereum network)

For consumers: Metamask; Mist Browser

- What it means to have an account: account address, public key, private key

What’s a transaction?

Click submit on the form👉address sent to the backend server👉backend server uses Web3 library to create a transaction object👉backend server sends the transaction object to the goerli network👉backend server waits for the transaction to be confirmed👉backend server sends a success message back to the browser

  1. Nonce: How many times sender has sent a transaction

  2. Value: Amount of ethers sent

  3. gasPrice: Amount of ethers the sender is willing to pay per unit of gas to get this transaction processed

  4. startGas/gasLimit: Units of gas that this transaction can consume

  5. v/r/s: Cryptographic data can be used to generate the sender’s account address. Generated from the sender’s private key.

Q: Why is blockchain so hard to understand?

It has to solve an incredibly difficult problem: the representation and transfer of millions, billions, and trillions of dollars between people.

Why do we have to wait?-Mining

The whole process of mining
The whole process of mining

Block time

A few clarifications on Ander’s video:

“Looking for a hash that starts with some number of leading zeroes” should be “a hash that is less than some target value.”

post image

[Block Time]The amount of time to run different possible hashes until we find the final value.

Solidity

contract definition (solidity)👉solidity compiler👉Byte code(deploy in Ethereum)

                                                                           👉Application Binary Interface(ABI)

Code

pragma solidity ^0.4.17;

contract Inbox {
    string public message;

    function Inbox(string initialMessage) public {
        message = initialMessage;
    }

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

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

Function declarations

function getMessage() public view returns (string) {

function name ☝function typereturn type

Common function types

Public: Anyone can call this function (who has Ethereum account)

Private: Only this contract can call this function

View/Constant: This function returns data and doesn’t modify the contract’s data

Pure: Function will not modify or even read the contract’s data

Payable: Might attempt to call it or send money to the contract

Testing with Remix

Contract source (remix editor)👉compilation to bytecode👉deployment👉In-browser fake network(inbox instance)

Running functions

Anytime we want to change any data that gets stored on the blockchain, we have to submit a transaction

Calling a function

  • Cannot modify the contract’s data

  • Can return data

  • Runs instantly(doesn’t need transaction)

  • free to do

Sending a transaction to a function

  • Can modify data

  • Returns the transaction hash

  • Takes time to execute

  • costs money

Wei VS Ether

1 dollar=100 cents

1 ether=1,000,000,000,000,000,000 Wei

Mnemonic phrases

12-word mnemonic👉BIP39 mnemonic algorithm👉account 1: Consuming; account 2: Saving; account 3: Business…