A1: Create a variable for each of the following: your favorite color, your height in centimeters, and whether you like pizza. Use appropriate variable declarations (let, const, or var). Try logging it using console.log.
A2: Write a function sum that finds the sum of two numbers. Side quest - Try passing in a string instead of a number and see what happens?
A3: Write a function called canVote that returns true or false if the age of a user is > 18.
A4: Write an if/else statement that checks if a number is even or odd. If it's even, print "The number is even." Otherwise, print "The number is odd."
A5: Write a function called sum that finds the sum from 1 to a number.
A6: Write a function that takes a user as input and greets them with their name and age.
A7: Write a function that takes a new object as input which has name, age, and gender and greets the user with their gender (Hi Mr/Mrs/Others Harkirat, your age is 21).
A8: Also tell the user if they are legal to vote or not.
A9: Write a function that takes an array of numbers as input, and returns a new array with only even values. Read about filter in JS.
A10: Write a function that takes an array of users as input and returns only the users who are more than 18 years old.
A11: Create a function that takes an array of objects as input, and returns the users whose age > 18 and are male.
Having more than 1 wallet meant having lots of public-private key pairs, HD walltets solve this problem
Having a HD wallet meant only need to backup private keys for recovery.
HD wallets allows you to store 1 single private key (SEED), from this seed you can derive many wallets, this is done using derivation paths
Derivation path eg : m/44'/60''/0' where m refers the root node, the 44 refers to the purpose, 60 refers to a blockchain, 0 refers to the wallets number.
44': This refers to the purpose field in BIP-44, which standardizes multi-account hierarchy for deterministic wallets. The value 44' indicates that this derivation path follows BIP-44.
Mnemonic : a 12 word combination made from 2048 words list, help you determine the seed phrase using this. This needs to be kept confidential.
Frontend vs Backend vs HTTP servers
A block explorer like solscan querys the block chain to fetch some data. this querying is happening via http requests.
A frontend request fetches things like html/css
A backend request fetches things like user data.
You can query different block chains using POSTMAN ( a type of universal block explorer )
POSTMAN lets you send post requests (backend requests)
Browser / Client like POSTMAN calls a func. present on an RPC server with some args. in json format, the rpc server return the output to the client. This is JSON RPC
JSON RPC does what an http request does, their appeal is that it seems like you are calling a function; under the hood its just an http request at the end of the day.
There are more things like TRPC, GRPC, etc which do useful things like compression...
ETH uses RPC.
The RPC server nodes sit close to the blockchain and talk to it.
There are companies which provide RPC servers as a service.
Common RPC calls like getting the balance were see in this class.
The data we receive is in units like Lamports or wei.
Any financial txn company stores your data in the form of integers not decimals because of precision issues, hence units like Lamports and Wei.
Creating a web based wallets needs knowledge of react, this will be covered in an offline video.
Instead of having HTMl code inside inner.html, we create a div,span,button elements; then append span and button to the div and append the div to the body.
State and Components:
State : the variable things that go in the Component
Component : the wireframe or the structure inside which the states are updated.
Rendering : updating the states in the component and showing it on the DOM.
Writing our own render function which pushes the todos from the todo array on to the component (written once) then shows it on the DOM, so we dont have to write the DOM logic again and again.
Reconcilliation : Updating the difference between the old state and new state onto the DOM. ( React does this optimally )
React does a lot of optimizations like batch updates, etc.
Stuff Harkirat told to do
Try to create a TO DO application using the advanced DOM manipulation we learned today.
BTC gave us decentralization of money, but we can do more using blockchains...
We can build entire applications like uber on top of the blockchain.
NOTE : it's a bad idea to build uber on blockchain, as they are really slow ( txn speeds )
A good idea : Creating our own token (eg : Dogecoin, Trump coin, etc) these are not blockchains in themselves, they are tokens made on top of existing blockchains.
Smart Contracts : some code you can write and deploy on a blockchain. ( SOL and ETH allow you to do this )
Accounts on Solana are data structures which store info ( your money, user data, more complex stuff aka Smart contracts ( == web 2 backend but deployed on blockchain ))
You need to pay some rent i(if min SOL balance for rent exemption not met, rent deducted, else exempt.) to have an account on it. ( its proprotional to the data stored in the account )
Today's class was incomplete beacuse it turned into a doubt session, watch the entire class here -> 🔗
Stuff Harkirat told to do
Install Solana CLI
Watch the offline video for today's complete class.
HTTP protocol allows servers to communicate with each other.
Request Response Model : communication pattern between the client and server ( there are other eg : Web sockets, WEB RTC, GRPC )
IF interested in making own HTTP server from scratch refer RFC 2616 -> 🔗
Chrome dev tools will be an offline vid.
Domain Name / IP : eg - google.com -> this has a remote address which translates to the IP:port no( try ping google.com or equivalent to get the IP )
If you rent a server from AWS you get a IP ( 22.27.37 ), THEN you can buy a domain (eg harkirat.kirat.me) from godaddy and then point harkirat.kirat.me to 22.27.37
Ports : logical endpoints that identify specific processes. eg: app.100xdevs.com/3001 points to a specific thing and 3002, 3004, points to other things but are on the same IP.
Default ports for HTTP = 80 and HTTPS = 443
Methods : ways to structure your requests.
Creating something -> POST request
Reading something -> GET request
updating something -> PUT request
Deleting something -> DELETE request
When you do a POST request you get a JSON ( Javascript Object notaion )
Status Codes:
3 digits num returned by the server to indicate outcome of client's request.
if something bad happens : it doesn't give 200 ok.
200 series is success ( 204 is req successful but no content to return )
300 series are redirects
400 series are client side errors.
500 series are server side erros. ( if you got this on your site, something is really wrong )
BAD devs don't use status codes (eg : the initial dev team at PAYTM )
Body -> while sending a request to the server if you want to send some data (payload), you use this.
Routes -> what exactly do you want to do eg: https ://api.todo.com/something -> the something is the route. it points to something specific.
WE generally dont create http servers from scratch.
In today's class we just touched express and how to build soemthing using express, the assignments of the todo app are based on this part of the class.
app.get('/',function(req,res)){run this code when GET request received from client}.
The '/' this is the endpoint it can be something like '/calendar'
req object gives access to all things related to the request sent by the client eg : if any payload is attached to the request sent, it can be accessed from here.
res object gives access to the thing the server sent to the client
app.listen(3000) the 3000 is the port.
Headers will be covered in another offline video if not already in the offline vid for this class.
Stuff Harkirat told to do
If this class was too overwhelming, watch this offline class : 🔗
Install POSTMAN
Easy assignment : code an in memory todo app (express)
Hard assignment : code a file system based todo app ( the backend part needed was covered (basics) in today's class, the front end part for fetch, cors will be an offline video )