---
# System prepended metadata

title: NEAR and Far from _any_ Coding v.3.4
tags: [near-and-far-tutorial]

---

# NEAR and Far from _any_ Coding v.3.4

## Course Outline 

---


## Welcome to the Course!

Anyone with a computer and internet connection can take this course.

If you are interested in making sense of Web3, but you don't know how to read or write code, then you are in the right place :wink: 

You might even be considering attending a NEAR certification course, but already feel lost. Don't worry. This course is a great first step for you.

--- 


## Learning Objectives

### a novice to Web3 will be able to:
- confidently describe the idea of the open web
- confidently describe broad blockchain concepts 
- identify core features of any smart contract (view function, change function, etc.) :heart:
- confidently reason about a dApp
- learn to ask good questions
- reduce anxiety about taking a certification course
- understand the difference between testnet and mainnet
- identify and navigate to core primitives in the NEAR ecosystem
- describe why NEAR is carbon neutral and Bitcoin is not
- discuss identity, governance, and ownership in Web3

---


## Course Overview :female-teacher: 

----

1. **You and your Computer** :computer: 

    - _Today computers take many different forms beyond laptops, tablets, and phones. The microchip to track your pet if they get lost? That’s a computer. Your AirPods are actually two computers, but they behave as one. These tiny computers are inside so many things we touch, but what are they? How can we learn to see them clearly?_

---

2. **You and the Internet** :computer: :telephone_receiver: :computer: 

    - _We often use the internet and web interchangeably, but in fact these are different things._ 
        - "The internet" refers to the _infrastructure_ 
            - **a network of networks** with rules for communicating, which keeps the web accessible at all times.

    - _The **web**, the pages we browse when we're online, is built on top of the internet._ 

---

3. **You and Web2.0** :spider_web: 

    - _Once we start talking about browsers and web pages, we are in the domain of the modern web._ 

    - _You've heard of servers, but when we talk about using those servers to access and share information, we can start to see the differences between infrastructure and how it's used:_
        - the internet (infrastructure) = highway
        - the web (information) = rush hour, and billboards, and buses - oh my!

---


4. **You and Web3.0** :question: :spider_web::question: 

    - _Now that we understand that visiting a web site(Web2.0) is different than the WiFi(Internet) that brought it to your device(computer), we can start to imagine other ways to connect to each other. That's exactly what Web3.0, or Web3, is doing. It's re-imagining the web!_

    - _When we talk about the “open web” we are talking about a system in which users have both freedom and transparency. As opposed to the "closed" systems used by certain governments to limit free access to information, the open web is designed to be a cooperative effort among a community of users and builders_

    - _Why is Web3 so powerful and important? Because it has the ability to side-step centralized power structures that govern the internet. Web3 is all about open access to information with a level of privacy not attainable previously. Getting around Big Brother is a pretty big deal, isn’t it?_

    - _Why is it called Web3? Today, Web3 generally refers to a type of network (of networks) that is still accessed through the existing internet, but with very different rules. Until Web3 fully breaks away from centralization, we can think of it and its infrastructure as another type of highway (like web2.0), but one where the toll roads pay YOU!_ 

---

5. **You and NEAR Protocol** :rocket: 

    - _If Web3 is a decentralized network, then what are the rules of engagement?_
    
    - _It's an exciting time for Web3. By now you've seen dozens of ads that mention cryptocurrency. You may have scratched your head at whatever an NFT is, or perhaps gawked at the idea of pixel art selling for millions of dollars in “imaginary” money with silly names like Dogecoin, Ethereum, or even NEAR._
    
    - _There’s a ton of activity in the Web3 space, but does one actually use it like you use the internet today?_

    - _Decentralized networks can pretty much make up their own rules of engagement, so long as the outside world can access the information passing through them._
    
    - _NEAR Protocol is exactly that - it's a system of distributed networks with its own rules, or **protocol**, for communicating._

---

# 1. You and Your Computer

---

### Think of your computer as your house

#### How would you describe your house to a computer?
- It's broken down into smaller rooms maybe?
    - what is a room?
        - a component of your house? :heavy_check_mark: 
- Each room connects via one or more doorways.
- You can add rooms to your house.
- You can upgrade and / or merge existing rooms.
- You can "optimize" the layout so it warms and cools more efficiently or creates feng shui.
- If it burns down, you can rebuild it based on blueprints, and you can replace most of the items in it. Unfortunately, some things may not be replaceable.


### Your Computer is a Machine

#### How do you think your computer is organized?

- you might think of words like "hard drive", and "motherboard"
- your setup might involve 1-2 external monitors, a bluetooth mouse, and wireless keyboard
- you might mention whether your computer is a Mac or Windows or Linux

#### Now think about how you use everything you mentioned. 
- your description of using your mouse is probably different than that of using your keyboard
- you may mention why you chose to buy a Mac as opposed to a Windows computer

#### When we talk about how each part of a computer is organized, we are talking about its various _interfaces_
- let's return to the analogy of your house
    - your kitchen is made up of a collection of interfaces
        - your stove has an interface
        - your fridge has an interface
        - even your faucet has an interface
        - you can interface with your kitchen's circuitry through your breaker panel 


:::info
:thinking_face:  Another way to think about interfacing is human-to-human communication
- we have interfaces of our own to communicate with each other without the need of any technology. They include:
    - our faces
    - our 5 senses
    - our expressions
:::

----

### _interfaces_ and your computer

Your computer is organized through two types of **interfaces**

#### _peripheral_ interfaces -- :desktop_computer:
  
- hard drive 
- keyboard
- mouse
- screen


----

#### _software_ interfaces -- :blue_book:

- interface drivers
    - programs or sets of programs
        - set of instructions that tell a piece of hardware how to function
- operating system
    - software that enables other software to communicate with hardware
- applications
    - programs designed for an end user
- scripts
    - set of instructions for another program to use

----

#### All of these interfaces "play" together to extend how your computer is used.

- hardware parts can be put together and taken apart again
- you can add new software and delete other software
- you can easily add multiple monitors, switch out keyboards, add a camera, etc.
- you can even run a _virtual machine_(**vm**), which is essentially a computer running inside your computer. In fact your computer has numerous VMs running at any given time.

#### this ability to break components down, and mix and match them is called _modularity_ :building_construction:
- the rooms in your house can be considered **modules**; same with your TV (a module), and your entertainment system as a whole (also a module).

---

### _data_ and your computer

----

#### What comes to mind when you hear "data"?

- information? :heavy_check_mark: 
- stuff that stored on hard drives? :heavy_check_mark: 
- electrical signals? :heavy_check_mark: 

How does information pass through your computer, and how is it stored for later use? 

It may seem trivial, but when we talk about technology, we soon start to look at what data is doing when it's **in motion** and **at rest**

- when we press a key on our keyboard, a signal travels to our computer's brain and registers the key we pressed. It's always listening for something to interface with it.
- when we save a file, our CPU gets instructions to store the contents of the file along with information about the file on our hard drive.


#### your computer handles **data** in two basic ways :memo: 

- **data in motion** :runner: 
    - from keyboard to machine
    - from mouse to machine
    - from monitor to your eyes
    - from speakers to your ears

- **data at rest** :sleeping: 
    - database
        - structure of how data is stored
    - hard drive
        - physical addresses where data is stored as 1s and 0s.

- back to the house analogy. What is the "data" of your house?
    - electricity and water systems?
        - water moving through your pipes when faucet is _on_ vs water stored in your pipes when faucet is _off_
    - pictures on the wall?
    - food in the fridge?
    - what about how your house is used - wear and tear?
        - in a way _you_ are your house's data since it's whole purpose is to handle _you_ in motion and _you_ at rest when you're using it

---


### _time_ and your computer :clock230: 

- it may feel strange to talk about time. Isn't it self-evident?
    - not as evident as you might think
    - our computers don't have to rely on time the same way we do
    - time is extremely important in web3, and we will soon learn that our idea of time is essentially thrown out the window when it comes to blockchain. 

- You can set time to whatever you want on your machine, but when two machines with different times talk to each other, we need to agree on what time to use.
    - this is just like when you make travel plans 
        - you need to double check timezones of flight and train times, for instance.

- What if _your_ computer is set 6 hours ahead of _my_ computer?
    - How do our computers do things at the "same" time?
    
---

## Your Relationship with Your Computer

----

### your _identity_ and your computer :selfie: 
    
- Your _User Profile_ is your **identity** on your computer
    - _Guest Profile_ can't change your password.
    - but if I have your password, I have your identity as far as your computer is concerned. 
    
----


### _ownership_ of your computer:key: 

#### What does it mean to "own" your computer?
- just like your house. You can remodel it, tear it down - anything you want, because it's yours, right?
- you can add / remove the programs you want
- you can add / delete files, media and other **digital assets**
- you can replace your mouse, your hard drive, and your monitor
- you can even toss your computer in a pond (make sure to take it back out though, we don’t want to be polluting ponds). 

----

### the _structure_ of your computer :classical_building: 

#### What happens if you do throw your computer in a pond?
- Is the data on it gone forever, because it was all **centralized** on your computer and your computer alone?
- Or is all or much of the data **distributed** accross one or more _other_ machines, and you only lost a portion of your data?
- Or, even better, is the data not only distributed accross multiple machines, but **decentralized** so that each machine has a copy of _all_ your data? :crossed_fingers:

---




# 2. You and the Internet

---

## The Internet is a Network (of networks) of Computers :satellite_antenna:

### Think of your neighborhood
#### How is it organized?
- houses connect to each other through shared **interfaces**
    - electrical grids
    - sewage
    - waste management
- each house has its own address
- clusters of houses comprise neighborhoods
- apartment buildings can be considered neighborhoods with each floor being a cluster of condos, have one main entrance, and maybe a front desk, to handle traffic in / out of building
- neighborhoods help cities manage how resources are distributed
- some neighborhoods are very densely populated :house_buildings::house_buildings::house_buildings:
- some neighborhoods are spread out :house::desert::desert::house:

### the internet is organized in a similar way to your neighborhood
- computers connect to each other through their network **interfaces**
    - ethernet 2.0
    - IEEE 802.11 
    - VPC / VPN
- each computer has an address
- clusters ( or **modules**) of computers, called **nodes**, comprise networks
    - these network computers are not designed to be used like your personal computer
    -  they are referred to as **nodes** to help clarify the distinction
- networks generally have one Network Access Point (NAP) to handle traffic in / out of network
- networks facilitate traffic (data) across the internet
- some networks are densely populated :computer::computer::computer: 
- some are sparsely populated:computer::desert::desert::computer:


:::info

:mailbox_with_mail:  When you mail a letter, you must properly address it, add correct postage, and any other rules or protocols set up by your region's mail delivery system or it will be returned. 

Networking **nodes** and **modules** isn't all that different (I mean, it is! But you get the idea )

:::

----

#### neighborhood health relies on people getting along, usually through some set of rules every neighbor agrees to follow
- some neighborhoods have HOAs 
- some neighborhoods have community boards
- some employ neighborhood watch shifts
- some have regular block parties

----

#### _network_ health relies on good node-to-node communication, and good module-to-module communication 
- each network has at least one access point (NAP)
    - _i.e. a front desk_
        - outsiders must talk to the front desk of your apartment building in order to talk to you
- these connections need to agree on basic rules called **protocols** that every **node** and **module** (cluster of nodes) must follow
- network protocols ensure that a connection between any two **nodes** will be available, reliable, and consistent 24 / 7

----

#### The set of rules that comprise how the internet works are called Internet Protocols (IP)
- Each node connected to the internet must have its own **IP address** so other nodes can find it. 

---

### _data_ and the internet

----

#### internet data is about connectivity

- **data** travels through the internet from one node to another until it reaches it's destination IP address. 
- think of it as the difference between a letter and the entire postal system
    - what is the "data" of a letter?
        - journal entry? :heavy_check_mark: 
        - to / from addresses? :heavy_check_mark: 
        - stamp? :heavy_check_mark: 

    - what is the "data" of a postal system?
        - routes? :heavy_check_mark: 
        - zipcodes? :heavy_check_mark: 
        - letter / package volume? :heavy_check_mark: 
    
#### data is handled in two basic ways on the internet
- **data in motion** :runner: 
    - data is broken down into packets
    - data reassembles when it reaches its destination

- **data at rest** :sleeping: 
    - some data is cached at NAPs
        - _your building's front desk "caches" info for all tenants_
            - i.e. _"Notice to all tenants: there will be..."_
    - service outages :skull_and_crossbones: 
        - nodes go offline
        - routers fail
        - congestion :traffic_light: 
    - data packets are cached in the nearest node
    - networks spin back up, and data packets resume travel
    - errors often occur when systems shutdown mid-execution

----

## _time_ and the internet :clock11: 

- Network Time Protocols (NTP) help networks sync time
    - one node is cast as the **layer 1** source of truth 
    - other nodes that sync with this node become **layer 2** nodes
    - other nodes that sync to layer 2 nodes become **layer 3** nodes, etc.
    - accuracy to 1ms
        - that's a long time for modern networks
        - if I have $100 and a super fast connection, I can wire you $100, my friend Bob $100, and my other friend Alice $100 - all before my bank realizes what happened.

- Your internet relies on whatever the network _thinks_ is the correct time.
    - it assumes the time given it by the network is trustworthy

#### We need to adjust and re-adjust how our computers measure time
- Y2K
    - Date formatted as YY instead of YYYY
        - '97...'98...'99...:fearful:
- Y2038
    - Unix time
        - counting the seconds since 1970
    - Imagine if a system could only count to 2,147,483,648 seconds 
        - and resets to zero each second after that...
        - we don't need to imagine it - just wait until 2038

  
---

## Your Relationship with the Internet

----

### your _identity_ and the internet :selfie: 

- Your IP Address is your identity
    - I may not know _who_ you are, but I know _where_ you're calling from


----

### _ownership_ and the internet :key: 

- you don't own your apartment building or the roads and sidewalks that make it accessible

#### who owns the internet? Not you!

- businesses built their own networks and eventually agreed to connect those networks
- network owners can take a node or entire network offline
- your computer's access to the internet is entirely governed by centralized networks 
    - You are at their mercy
    - You pay for a service, not a right
- you have no say in how internet protocols are decided

----

### the _structure_ of the internet :classical_building: 

- The Internet is **distributed**
    - It doesn't go down when one node or network goes offline
        - _your_ internet going down isn't the same as _the_ internet going down

- The Internet _used_ to be **decentralized**
    - One computer connected to another computer, and so on

- The Internet quickly became **centralized**
    - each network has one access point (NAP)
        - one door to open or close
        - one point of failure for the entire network
    - network owners in control
        - access decided by a small group of people
        - vast distributed systems with numerous access points still controlled by a a handful of decision makers

---







# 3. You and Web2.0

----

## The Internet is _not_ the Web 

- neighborhood layout vs block parties
- infrastructure vs information
- highway vs rush hour (and billboards and bus rides...)
- _network_ **interfaces** vs _web_ **interfaces**

:::info
#### :thinking_face: what happened to Web1.0?
- Web1.0 worked like a giant encyclopedia
- it can be considered a content delivery network (CDN)
    - content was simply delivered to your computer
    - _generally_ you couldn't update the information served to you.
- Web2.0 extended how the web was used by allowing users to "interact" more with the web
    - think of the book "Tarzan" vs the book "Choose your own adventure: Tarzan" (or "MadLibs: Tarzan")

:::

----

### the web is the information users access on the internet
- it's the mail that is delivered to houses in your neighborhood

#### web _interfaces_ = applications and browsers
- application interfaces interpret each other's instructions
    - Application Programming Interface (**API**)
        - APIs are each application's **interpreter** when other applications talk to them 
    
----

#### the Web is servers and clients
- servers and clients are computers
- servers are the _back_ end of the web
- clients are the _front_ end of the web
- clients make requests to servers
- servers listen and respond to requests from clients 
- servers talk to other servers on behalf of clients

:::info
#### :thinking_face: how do servers "listen"?

Servers use **ports** to listen for events. Ports are like your mailbox. Your mailbox isn't your address, but it's where you send and receive mail. Ports are like a server's mailbox.

:::

----

#### servers are everywhere

- your keyboard sends requests to the input server running on your computer that listens and responds to every key you press
- your dog's smart collar is a server
- servers just need a port so they can listen and respond to requests
- web servers are servers that use web protocols like "http"

----

:::info

#### :thinking_face: why are appliances becoming "smart" now?
- more and more consumer goods now have tiny servers in them

##### for example:
- alexa listens to me say "turn off lights" 
     - her microphone receives my sound vibrations
        - it transduces my command to bytecode her api can understand
- alexa converts the bytecode of my request to a signal that my smart bulb's API can hear.
    - my smart bulb's server has been listening for any requests to its API all day
- my smart bulb receives the request and routes it to a function that executes the turning off of the bulb
- this networking of objects with tiny servers in our homes is called the Internet of Things (**IoT**)

:::

----


#### the web is _organized_ and _designed_ for user experience (U/X)

- WordPress used to be the convention for web design
    - each page was a pre-designed template
        - limited control of layout
        - all pages looked / behaved the same    
- **modular** design breaks the page into the tiniest, customizable components or web resources
    - it allows flexibility in deployment, arrangement, and customization
        - a web app is composed of different scripts, libraries, smaller apps, etc., but can be deployed as a single entity, and therefore follows this idea of modularity
    - granular control
    - web pages grow / shrink responsively to screen size and device type

---

### data and the web

----

#### **data** is broken down and passes back and forth between your computer and multiple servers

:::info

if I want to send you a postcard, but I have so much to tell you that I have to write it out across 10 postcards, I might number each postcard in case they don't all get delivered at the same time, so you can reconstruct them in the right order once they all arrive

:::
- **data in motion** :runner: 
    - data broken into smaller web packets that travel between client and server(s)
        - if a packet says it's number 4 in a list of packets, and your computer hasn't seen number 3 yet then your data waits until the other packets arrive before it gets reassembled

- **data at rest** :sleeping: 
    - local storage
        - data stored in your browser with no expiration
    - session storage
        - data cached in your browser until you close the browser window

----

### _time_ and the web :clock1: 

- "trusting" what a server somewhere in the world tells us is the correct time
- UCT solution - time based on the Sun and Earth's rotation
    - needs mass adoption
    - impractical that noon UCT would mean noon all around the world
- faster connections make syncing time more and more difficult
    - bad things can and do happen on the web in a blink of an eye

---

## Your Relationship with the Web

----

## your _identity_ and the web :selfie: 

- you are your _activity_ on the web
    - your browser history 
    - requests coming from your IP address
    - your activity in and accross other web apps (shared data)

- your email is your _main_ source of identity
    - it relies on a web mail protocols to function
    - you can use it to log into numerous web apps
    - password _plus_ information from another device (2FA) required for identity verification

- access to your identity is at the mercy of internet service providers and app owners
    - Twitter can lock you out of your account
    - your ISP can shut your internet access at any point
        - new internet plan? no problem - except now your router is no longer compatable, and you'll need to upgrade that before you service is restored :woman-shrugging: 

----

### _ownership_ and the web :key: 

#### you don't own your data
- your data (activity history) is being sold constantly
    - you don't make a dime from it
- cloud admins can delete any data you store on it
- your accounts can be taken offline with just a few strokes
- Instagram can use any pics you posted any way they want
- it only takes a handful of people to completely block your access to any digital assets you "own"

----

### the _structure_ of the web :classical_building: 


- The modern web is distributed in a _centralized_ way
    - _distributed_ networks managed by handful of tech companies
    - very few points of failure can bring entire regions offline

- The modern web is _very_ centralized
    - 4 big box stores to shop at
    - monopolies mean that fewer and fewer people hold the keys to the kingdom

---







# 4. You and Web3.0

---

### Web3 is the _decentralized_ or "open" web :open_hands: 

- network interfaces follow new rules
    - no one node is in charge
    - no single NAP
        - _no front desk_

- no one can "turn it off"
    - it's accessible to all
    - it's owned and operated by the people using it
    - there are no middlemen
        - no brokers between you and the stock market
        - no bank fees for managing your money
        - no HR between you and payroll


#### network of computers across the globe act as one computer sharing a single state

:::info
#### :thinking_face: what's "state" in the neighborhood analogy?

When a new house is built in your neighborhood, all the phone books need to update to reflect the new addition. So, a new phone book is sent out to all the neighbors with the address, etc. of the new house. 

:::

- change state of one, you change state of all
    - we are Borg :robot_face: 
- when one node registers a change in the network (state) it gossips about it to the other nodes
    - gossip spreads about the change in state to the entire network

#### Web3 _interfaces_ are accessed using Web3 accounts
- "log in with your email" becomes "log in with your Web3 wallet"
- connections to Web3 architecture occur through http connections and **smart contracts**

#### contract _interfaces_ manage changes in state
- they are a set of instructions (like any other program) for updating state/data/transaction history
- the updates that nodes gossip about are triggered by methods in these contracts
- contract methods allow Web3 accounts to either  _view_ state/data/transaction history or _change_ state/data/transaction history
- contracts that take a lot of time to run can congest the network
    - transaction fees (GAS) help prevent this
    - they incentivize developers to optimize their code so it execute faster, and consumes fewer resources (cheaper!:money_with_wings:)

----

### Web3 is composed of interconnected layers
- these layers behave like **modules** and can be broken apart and reconfigured to create new use cases

_**[REVIEW SHERIF'S ZOOM ORIENTATION FROM 3/04/22 ~ 37min in. He talks about the effects of mixing Time, ownership, identity - use here!!]**_

#### protocol layer 
- base layer
- blockchain architecture
- changes to data are stored as transaction receipts on a digital ledger
    - ledger is copied and distributed to all nodes in the network

#### infrastructure layer
- interoperable building blocks
- modules connect together for specific tasks
    - storage
    - naming service
- **smart contracts** serve as the _back_ end of Web3 infrastructure
    - contracts manage state
        - they are like interpreters 
    - web3 accounts "sign" transactions the same way one might sign a lease agreement or credit card receipt

#### use case layer
- where it all comes together
- DeFi, Gaming

#### access points
- top layer
- users sign into their account(s) and send / receive crypto-currency

----

### Web3 needs Web2... for now :handshake: 

- Web3 infrastructure is different than web2, but still new and generally limited, so it can't operate without web2 yet 
    - you still need the centralized web to access the decentralized web
    - it's not immediately apparent when you are using a Web3 app (dApp)

---

### let's finally talk about the "blockchain"

is it a ledger? :heavy_check_mark: 
is it a database? :heavy_check_mark: 


#### the blockchain is..
- transaction history

the blockchain is like a stack of milk crates with each crate containing piles of various transaction receipts. The stack of crates gets higher with every new batch of receipts.


:::info
:bookmark_tabs: Imagine if instead of receiving a new phone book every time a new neighbor moves in / out, you (and everyone you know) receives a single page from the phone book with just the updated information. 
:::


---

### _data_ and Web3

----

- **data in motion** :runner: 
    - _data-as-state_ alerting each node in the network
    - state copied over and over to every node
    - state changes create a _new_ phone book
        - you can see the entire history of the data 

- **data at rest** :sleeping: 
    - data stored "on chain" remains in tact forever

        - you can view it, but you can't _change_ its history
            - _you can build a house on an ancient burial ground, but you can't change the fact that there was an ancient burial ground where you built your house_
        - updating data means creating a new entry in its transaction history
    - not all Web3 data is stored on the blockchain
        - conventional data storage solutions still in heavy use
            - browser storage
            - (centralized) database storage

---

### _time_ and Web3 :clock1030: 

----

### the blockchain is... 
- a clock :exploding_head: 


#### time is measured in _block height_
- each block added to the chain increases its height 
- some blockchains add a new block at a constant rate even if the block is empty of updates to transaction history
    - this allows for planning
        - _"let's meet at 3pm"_ becomes _"let's meet when the block height reaches 89489830340"_


#### consensus among the nodes (i.e. >50%) sets the current block height (time)
- community board meetings exist for the purpose of finding consensus community-related initiatives. Community-based blockchain networks are no different, and people don't always agree

- sometimes two nodes with different block heights claim to have the most current (highest) chain
    - ( generally ) longest chain wins

- sometimes nodes do not agree with the consensus and continue with _their_ version of the blockchain
    - if other nodes join them, then a fork is created
        - two versions now exist
            - Ethereum vs Ethereum _classic_

- sometimes infrastructure updates require a fork
    - if a node with the old version of the chain exists, the old infrastructure is still accessible

        - you can keep your old phone books, and use them, but they will become more and more unreliable
        - you can keep your computer from 1997, but it won't be able to "dial into" today's internet like it did when Austin Powers was in theaters. 
  

#### trustless proofs provide integrity of the blockchain so you can trust the time it gives

- proof that a transaction is valid can be achieved through cryptography
    - if anything changes in one block, all subsequent blocks are _immediately_ invalidated
        - we see this in time travel movies
            - change the past, you change the future 
    - _mining_ or Proof of Work (**PoW**) is how BitCoin and Ethereum create trust in their networks
    - PoW has become very energy-intensive as the blockchains that rely on it continue to grow
        - other proof concepts are being employed in new and existing blockchain networks to address these and related issues

---

## Your Relationship with Web3

----

### _identity_ on Web3 :selfie: 

- your web3 account is your identity
- no Oauth
- your offline identity is yours to reveal or keep hidden as you see fit
- the account(s) you use to explore the space build reputation
    - reputation / street cred helps build trust in the platform
- active engagement in the community is core to a successful, community-run web

----


## _ownership_ on Web3 :key: 

- _you_ own your data, and _you_ own the network

    - no. seriously!
    - everything is flipped on its head
    - you earn money from simply engaging the network
    - ad companies pay _you_ to see their ads rather than google

- networks have their own economies based on their specific token or **crypto-currency**
    - Bitcoin, ether, doge, $NEAR
        - if it's not Bitcoin, then it's an altcoin
    - tokens in your wallet are yours to do as you wish
        - if your country freezes bank accounts, your crypto is still safe and accessible
    - digital assets are yours
        - whatever digital assets are associated with your account are yours for as long as you desire
        - there is no repo man 
        - you are your own security

----

## the _structure_ of Web3 :classical_building: 

- Web3 is _decentralized_

    - there is no single point of entry or failure 
    - if one node goes offline, the data is preserved on all the other nodes
    - no _one_ controls the network
    - everyone controls the network
    - the wealth that is generated by the network is distributed among the people using it

- Web3 relies on Web2 to exist
    
    - Web3's infrastructure is decentralized
    - Web3's access layer relies on Web2 servers
    - contracts compile to webassembly so they can run in Web2 browsers









# 5. You and NEAR Protocol :fireworks: 

---

#### Web3 is a network of blockchain networks, and NEAR is one of them 
- not all blockchains are alike

- **NEAR** is a Layer 1 (L1) blockchain
    - layer 2(L2) blockchains use architecture of existing blockchains
        - Polygon is built on top of Ethereum, which is a layer 1 blockchain
    - NEAR is built from the ground up
        - NEAR has its own chain with its own rules and architecture
- Instead of **PoW** to create trust, NEAR uses Proof of Stake(**PoS**)
    - **PoS** is humans validating transactions, and staking a large amount of money that they will be honest about it
        - validators can earn historical returns on their staking
        - it's cheaper to tell the truth than to lie
        - validators get "kicked" off the network if they don't follow certain rules 
        - PoS is CARBON NEUTRAL :earth_americas: :heart: 

---

### NEAR has the same interfaces as other Web3 networks

#### protocol layer 
- base layer
    - L1 blockchain
- blockchain architecture
    - nodes split into mini processors (sharding) to improve network availability
    - PoS validation
    - localnet for dApp development
    - testnet for testing dApps
    - mainnet for launching dApps

#### infrastructure layer

- nodes are virtual computers you can download locally
    - when you download a node locally, you can refer to it as a client node since it will be interacting with the network in a similar way that your computer does.

- indexer nodes
    - nodes anyone can run locally to listen to network updates
    - querying all blocks in the chain can be cumbersome
    - Indexer makes it easier to search the blockchain
        - Google indexes web pages so they are easier to find



- block nodes
    - contain copy of the blockchain to increase network availability 

- archival nodes
    - contain copy of the _entire_ blockchain from its genesis


- validator nodes
    - nodes used by validators to review transactions



- [Wallet](wallet.near.org)
    - account management



- [Explorer](https://explorer.near.org/)
    - transaction history of any account



- [JSON RPC](https://docs.near.org/docs/api/rpc) (Response-Procedure-Call) 
    - API for interacting with the blockchain



#### use case layer
- DeFi
    - [ref.finance](https://ref.finance)
- Gaming
    - [berry.club](https://berryclub.io/)
- Bussiness Development
    - DAO
        - [Sputnik](sputnik.fund) 

#### access points layer
- top layer
    - Wallet
    - Explorer
    - JSON RPC

----

- NEAR's infrastructure of **modules** can be broken down and reconfigured for new use cases
    
    - create new primitives like message protocols
        - [Machina](https://medium.com/nearprotocol/introducing-machina-the-worlds-first-proof-of-stake-storage-solution-built-on-near-fed2ed23dbfb) is a PoS decentralized storage solution built on NEAR
    - dApps can use any number of primitives for their use cases
        - how would you create AirBnB on NEAR? 

---

### data and NEAR

----

- **data in motion** :runner: 
    - data travels accross many different protocols within the network
        - data fetched from centralized and /or decentralized database 
        - transaction data retrieved from JSON RPC and broken down into http packets that are returned to client
        - data about chain state propagated to entire network like gossip

- **data at rest** :sleeping: 
    - immutable data stored on chain
    - data stored in browser local storage
        - access keys
    - data stored on local machine
        - access keys
    - data temporalily stored in memory while dApp is running
        - access keys
    - data stored on _decentralized_ databases
        - IPFS
        - Machina

----

### _time_ on NEAR :clock12: 

- current block height is accessible to anyone with a computer and an internet connection
- new blocks are added every second
- some blocks contain zero transactions
- transactions _you_ make are queued using **nonces** (tally of transactions a given _key_ on _your_ account has made)
    - tx with nonce#4 isn't added to the chain until nonce#3 has been added

----

## Your Relationship with NEAR

----

### _identity_ on NEAR :selfie: 

- your mainnet account (_yourname_.near) allows you to interface with any other account
    - subaccounts you create (_myname_.yourname.near) can build your reputation
    - you are paid in $NEAR for your engagement in the network
        - earn to play
        - earn to learn

- contracts have accounts as well
- accounts can have zero or one contract deployed to them
- your account associated with your NEAR wallet does not have a contract deployed on it

----

### _ownership_ on NEAR :key: 

#### you have complete control of your account
- your wallet works like a keychain
- you can create keys for your account
    - key pairs - private and public, actually
    - private key is stored on your machine
    - public key is used to sign transactions
    - when you sign a transaction the transaction verifies that your hidden private key and your public key are indeed a valid key pair
- you can authorize dApps to add permissioned keys to your account
    - like when you give a valet a special "valet key" to park your car
        - the valet key has just enough functionality to get the task done
        - dApps basically do the same thing
            - they give you a **functional access** key
                - you can only call certain functions on the dApp's contract with it
                - you don't have **full access** 
                    - **full access** keys allow you complete control over an account
- you can de-authorize a dApp on your account
    - this is like signing in with google
        - google confirms you are authorizing the app on your google account
            - you can set special permissions like allowing google to read and edit your calendar
        - you can de-authorize any web apps associated with you google account too - web3 is very similar
- you can delete all keys from your account, and render it inaccessible by anyone (including you!) forever

#### you are your own security :lock_with_ink_pen: 
- no one can remove assets from your wallet without your permission
- if someone gets your private key, however, they have full access to your account
    - your funds are at the whim of whoever has your private key
    - :warning: **!!!NEVER SHARE YOUR PRIVATE KEYS!!!** :warning: 
    - there are no middlemen in Web3
        - no one at NEAR has the ability to "reset your password"
    - be vigilant! 
        - store your seed phrase outside of any devices connected to the internet
        - rotate your keys periodically



:::warning
:female-police-officer:  **Beware of phishing scams!** Quite often scammers will try to trick you into revealing your password with fake wallet sites. Always check the url of the web page you are on. 
:::

#### transactions are irreversible
- if you send / receive funds **no one can reverse the transaction**
- your transaction history is available to anyone at anytime
    - hyper-transparency
    - no privacy on the blockchain
        - do not store anything you aren't ready to share with the rest of the world

- NEAR has standards the NFT contracts must follow to be considered current and credible
    - if an NFT contract lists you as the owner of a digital asset, your ownership is indisputable.

----

### the _structure_ of NEAR :classical_building: 

#### NEAR is _decentralized_
- NEAR is community based
- NEAR doesn't own any nodes on its network

#### NEAR is part of Web3, and therefore relies on Web2, which is very much centralized

---

## resources:

web3 - start using Brave browser (looks and feels like Chrome) and have ads pay _you_ to view them

NEAR - check out what's being built on NEAR awesomenear.com



---

## epilogue

---

#### what questions to ask?
- remember, although we are building something new, the ideas have been around for a long time.
    - at it's core, the web is just requests and responses between clients and servers; if that relationship isn't clear when reviewing a dApp then your questions should investigate that 
- Hopefully, the analogy of your house and neighborhoods being like computers and networks will help you make sense of distributed systems
    - When you hear "node", you now know that could mean several different things:
        - some sort of computer, right?
            - probably a computer in a network
        - did you know "node" could also refer to a programming language called NodeJs?
            - many contracts are built in a "node environment". When you hear "environment" it's usually a clue that they are talking about NodeJs.


        


























###### tags: `near-and-far-tutorial`





