0.1 - EVM, Ethereum
Understanding the General Purpose Blockchain, Ethereum. This is a 1-page breakdown of EVM's documentation to help bring clarity for those wondering how the blockchain works. Enjoy the read.
Last updated
Understanding the General Purpose Blockchain, Ethereum. This is a 1-page breakdown of EVM's documentation to help bring clarity for those wondering how the blockchain works. Enjoy the read.
Last updated
This is an entire breakdown and narrative of the Ethereum documentation with details explanations, examples and resources to get you ready to become a Bridge Builder Member.
First proposed in 1982, blockchains were devised as a protocol for verifying transactions in a sequential manner on a distributed Network. Satoshi Nakamoto setup bitcoin in 2008 Using a similar hashing algorithm to Hash cash to implement the first blockchain, the Bitcoin blockchain. Blockchains consist of blocks of verified transactions that contain a timestamp and hash verifying its validity on the chain.The advantage of blockchain is that by being on a distributed peer-to-peer Network, they can allow, individuals to anonymously make transactions without a centralized banking Authority. They also prevent hackers or scammers from exploiting the system and faking transactions by having a cryptographic hash algorithm that makes this difficult to do. Blockchains facilitate the entire crypto economy, making up the backbone of any DeFi (Decentralized Finance) solution.
The cypherpunks manifesto was written in 1993 by Eric Hughes. We can describe this movements action through its cause; The Cypherpunk Manifesto's mission was too openly Disparage centralized corporations and Global governments due to their lack of regulatory concerns and arbitrage. This is done by trusting the community to regulate the behavior of cryptocurrencies, or digital assets like money - instead of the global superpowers at large. These community members are known as, Cypherpunks. Those who actually code and build on the blockchain and enable cryptography to secure privacy for individual citizens in the face of government surveillance. This has led to a new wave of open source development and community services for the masses. Eventually Vitalik Buterin, the creator of Ethereum would take their sentiments and express it in terms of developing the Ethereum blockchain which enables developers to build their own businesses and decentralized applications on the EVM ("Ethereum Virtual Machine").
Vitalik Buterin started working in 2011 as one of the editors of Bitcoin magazine, subsequently winning a $100,000 scholarship from Peter Thiel in 2014 for his work. Prior to this he had been involved in math olympiads and had a fellowship with a cryptographer Ian Goldberg.
Vitalik Buterin
Ethereum started as a white paper that he wrote in 2013 proposing that Bitcoin adopt a scripting language to enable Smart contracts. After failing to gain support he decided to create his own new platform, named Ehereum. After launching in July 30th of 2015, Etherium has gone through many changes. In 2016 the first major change, the DAO Event, led to the forking of Ethereum classic from Ethereum. Today, Ethereum is the most actively used blockchain in the world in terms of value of daily transactions.
The Ethereum coin. Cryptocurrency. Used to facilitate transactions on the network. Essentially, can be thought of as "energy" or fuel used to run the network. Hence why the term "gas" is used to refer to the transaction fees or costs of doing transactions on the network.
This is what the Cryptocurrency network looks like in action...
You may also be wondering, how is the ETHEREUM coin made? You're probably questioning whether or not if it's anything like real money.
Well, it is! It's a lot like money!! Except that it has code that can give it rules, like the option to be inflated or deflated 🤔 ...
It's digital currency. It's 🤓 "Smart money".
It's a better, faster and more efficient Gold 🏆
Adding new blocks to the chain requires people (nodes) to solve a difficult puzzle that requires a lot of computing power. This "puzzle" is an algorithm which is used to verify transactions to add to the ledger. You need a powerful computer or "ASIC" to perform mining activities effectively.
Ethereum keeps a copy of the state of the entire blockchain, which is a huge ledger of transactions ran by billions of people. The people who make sure the blockchain operates effectively are miners who all run nodes which are computers connected to the Ethereum virtual machine. Miners are rewarded for whoever solves the consensus algorithm first, then wins a prize. This prize is Ethereum tokens. Everyone in the network agrees that that one person won the prize and they all agree to add it to the ledger. Everyone in the network keeps a copy of this Ledger. If you question the integrity of state of the blockchain, you may Requests for computation, which is called a transaction request
. No transaction can be messed with after it's sent and agreed on which means that it was signed and executed with appropriate “permissions”.
For security purposes, No one can send assets on my behalf unless they are me. All participants create a massive ripple effect that all participants can see in any block explorer, like Etherscan.. Once something is added to the blockchain, it can't be modified! Transactions are also locked behind a wall of permissions wherein no one else other than you should be able to sign in and send money from your account. 🔐
Ethereum Virtual Machine(EVM) is its full name. This computer is a state everyone on the Ethereum network agrees on. Any participant can make an arbitrary computation. This is literally just a random mathematical computation, it randomly chooses miners to execute blocks too mine. Don't worry if you don't understand what that means, you will learn more about mining and the state of the blockchain later. Other participants in the network can then carry out the computation which then causes a state change, distributing all throughout the network.
LOCK: Once something is added to the blockchain, they can't be modified. Think of a transaction like a non returnable purchase.
LOCK AND KEY: Transactions are also locked behind a wall of permissions wherein no one else other than you should be able to sign in and send money from your account. Just like a bank account.
Arbitrary Computation
ar·bi·trar·y : based on random choice or personal whim, rather than any reason or system.
The EVM has an algorithm that it cannot solve on its own. The EVM is like a bunch of people training a baby to walk. The EVM can't make decisions on its own, without the help of someone else solving it's algorithm over and over. Since so many people are helping solve the EVM's problem, there is an arbitrary precision (random reward system) that all nodes share on the EVM. All of these nodes are solving the same problem that Ethereum has, which is the proof of work
algorithm. The EVM chooses at "random", the 1 node that is able to solve the computation the BEST to produce the next block. Sound easy enough?
In simple terms Ethereum, logs transactions for payments across a network of users using the same digital infrastructure; it is a public network providing computation for all the web3 users and other existing services. There are many blockchains that have their own networks, like Harmony, Solana, Avalanche, Cosmos with different blockchain architectures & advantages. Ethereum acts like the electricity bill for the blockchain network, which pays contractors who supply the electricity usage. Ethereum pay's a fee to people who pay to use the permission-less network (Blockchain)
→ Fee's are BOUNTYS 😈 A bounty is awarded to whoever does the work of verifying the transaction on the blockchain. Bounties are also rewarded by people who need to solve problems for the blockchain; which can be a full time job for some programmers.
Imagine if someone wanted to flood the network with massive amount of transactions (This can also be known as a DDOS attack) that was done to crash the entire blockchain!? Fortunately, everyone using the EVM would never spam the network with transactions because it would be very expensive to do so. It is like a paywall to prevent attacks. theoretically, you could try and DDOS the network, but only if you have an incredibly large amount of money.
Take note : From the Ethereum Documentation
Ethereum, known also as "Ether", allows the existence of a market for mass adoption and computation. This market allows participants to verify and execute transaction requests and to provide computational resources to the network over the internet of things (web3). This is essential to understand, because when someone broadcasts a transaction request, someone else also has to verify that same transaction; that takes work, and work should be paid for. This person is paid (receiver) for their work with ether offered by the person (sender) who broadcasts the request. "Ether is a function of the length of computation". This prevents people from clogging the network, essentially preventing it from suffering from a DDOS(denial of service) attack. Every time you try to spam the network, it would incur a fee. It would be very expensive to attempt a DDOS attack. Each transaction also has a limitation for how many steps it will take. Feel free to come back and read this however many times you need - it is a good refresher!
Data that is taken from multiple computers in a network of computers and is continually updated on a ledger that is made up of blocks in a sequential chain hence the name-blockchain. These transactions are mathematically verified before being added to the block, and when a block is full, a new one is made to accommodate new transactions. Think of it like a transport train, There is no need to add more cargo capacity if the previous cargo hold isn't even full. This keeps the whole process as efficient and secure as possible.
The transaction that any one person makes, is data that needs to be added each block. "Chain" refers to the fact that each block cryptographically references its parent. A parent, is the block before the next block. Block 1 is the parent of block 2 and 3. In order to mutate a parent Block, all blocks must be convinced to change the state of the network. Each new block is known as a "node", these nodes mine computer algorithms which is the proof of their work to settle a transaction. If a block is added, then that node is rewarded. To summarize: when you send ETH to someone, the transaction must be mined and included in a new block. The updated state is then shared with the entire network. 🕸
Definition in learning guide (Terms)
Data and state stored in batches. Transaction data needs to be added to a block for the sent ETH to be considered successful.
Each block refers to its parent block. A block's data cannot be changed without changing all subsequent blocks. The entire network needs to agree that the chain must be changed. Each computer in this network is known as a node. This agreement is done through a consensus mechanism
We talked a lot about transactions and how miners are validating these transactions, but where are they all coming from?
You put money in, you get something back automatically when you put in your money. The smart contract knows how to implement the transaction [ example: {buttonCode = '123'} -> [ function__Disperse {if button_Code == '123' {dispense "cookies"]. The contract has a parameter set to give you 1 cookie pack if '123' is pressed and given the correct amount of money and will not infinitely loop to give you infinite cookies.
Coders aren't writing new code to make smart contracts, Coders upload to the EVM cloud, and customers request these codes to execute to perform for their business. Of course, there are limitations with how often a smart contract is offered, this is its "Parameters", like a boundary.
To launch a smart contract, users and developers pay a fee to use the blockchain as a data layer for their application. Smart contracts can be used to make marketplaces, financial instruments, games, and so much more.
Defi Exchange, finance and trade assets.
NFT Video Game, play to earn.
Art Gallery for Ethereum Market Place.
Decentralized: Independent and no one can control them as a group.
Deterministic: Performing the same function no matter where they are executed
Turing complete: Given the required resources, the dapp can do anything.
Isolated: Being executed in a virtual environment known as the Ethereum Virtual Machine so that if the smart contract happens to have a bug, it won't ruin the blockchain network's functioning.
https://cdn-media-1.freecodecamp.org/images/oNsxhuB9bVacGDh7pJyMjjk25gyipzS70lJg
No downtime: Once the smart contract is deployed on the blockchain, the network as a whole will be able to serve clients seeking interaction with the contract. Malicious people seeking to launch denial of service(DDOS) attacks can't do so.
Privacy: You don't need to supply real-world identity in order to deploy or interact with a dapp
Resistance to censorship: No one can block users from interacting with transactions, dapps, or blockchain.
Complete data integrity: Data stored cannot be forged.
Trustless computation/verifiable behavior: smart contracts can be analyzed and are guaranteed to execute in predictable ways without needing to trust a central authority. This allows our data to be kept safe.
Dapps have backend code running on a decentralized peer-to-peer network. Conversely, an app runs backend code on centralized servers. Dapps can have decentralized storage to host its frontend. A dapp at the most basic level runs a smart contract on its backend with a frontend to handle input. An important distinction between a smart contract and a dapp, however is that a dapp can - in theory - have an unlimited number of anonymous parties involved or agreeing to its terms, whereas a smart contract in the strictest sense of the word is merely a machine-readable agreement between two different parties on different sides of a market. Dapps are the software implementation of the smart contracts on the Ethereum network, in the same vein that checks are a physical paper implementation of an agreement between two parties to pay for goods and services.
Dapps have decentralized storage to host their frontend, which is used to handle input while the backend runs a smart contract.
A Dapp's backend consists of smart contracts, which are the aforementioned agreements between parties on different sides of a market(i.e. buyer and seller), connected by a message bus or protocol that then ultimately connects to the Ethereum network through a gateway, finally with a private key solution at the bottom of the stack, allowing transactions to be verified. A private key solution can be physical, software or some combination thereof.
A private key solution is used at the bottom of the stack to allow transactions to be verified. A private key solution can be physical, software, or some combination thereof.
Benefits of Dapp Development
No downtime, privacy, resistance to censorship, complete data integrity (it can't be forged), and trustless computation/verifiable behavior.
Implications of Dapp Development
Maintenance: Dapps are harder to maintain since blockchain isn't easy to modify.
Performance overhead: Scaling is hard. Back-of-the-envelope calculation puts the overhead at something like 1,000,000 times that of standard computation.
Network congestion: If Dapp is using too many computation resources, the entire network gets backed up.
User experience: For the average person, it might be hard to set up a tool stack necessary to interact with the blockchain in a secure way.
Centralization: User-friendly and developer-friendly solutions might end up looking like centralized services anyways. This ends up eliminating the advantages of using the blockchain by relying on a centralized service to store blockchain-related paraphernalia.
This next section is for your own review. Mining and arbitrary computation, are two concepts that won't need to be learned in order for you to code. It's only for your benefit to learn these concepts to have a greater understanding of how your code will be handled on the blockchain
Up until now, you have discovered what Ethereum is and what it's used for. The applications that can be built on top of Ethereum range anywhere from exchanges, to apps, brand new currencies, digital art collectives, games and a wide range of other services. Here are some of the things professionals must consider before creating Ethereum Applications.
Many types of modules that can be built on the blockchain for added use. All of these must be taken into consideration in order for the blockchain to run services that we all love to use with permission-less access.
Blockchain: All blocks are orders from the starting point called genesis block. Every node commits to the block network in order of computational efficiency. first in, last out... except, there is no out. The data coming in must be small in order to run smoothly, or else the storage costs would be enormous.
Accounts = Digital wallets filled with Etherum holding up the state of the network.
send money, write the deal down on paper and save it, and then do the job that is worth the amount paid for the job it wants to perform. Exact amounts matter to a smart contract. if I wanted to pay 50% of a contract, I would never be able to because it would break the rule.
Nodes: Any computer who gossip about evm. Nodes can also be validators. They are the most important backbone of Ethereum. Every node has the same record of the blockchain. The United States has the most nodes numbering in the thousands! there exists a Global map of computers, all storing information of the blockchain. Since any trustless peer can run a node, ( to prevent malicious behavior) cryptography is used by the EVM to secure users talking with malicious nodes. So if you are someone who is too trustworthy, be aware of what contracts you are interacting with. For your own security, make sure you check the links of ever site you interact with on web3. Full nodes secure the network, so if you're looking to become a secure node yourself, consider running a full node, vs a light node. Node = EVM Provider, a block
Decentralized: Independent peer to peer network. no one can control the entire blockchain, because it is decentralized and operated by many participants on the network.
Brute force trial and error wherein one can add a block and is thus rewarded ETH. New blocks added this way are announced 🗣 to every node, updating the entire blockchain state for everyone.
Be aware that all of these terms can be found in our terminology section which we've posted for you → here
Web1 was basic HTML sites, email / internet exploring, article browsing and portfolio sharing.
Web2 is the internet today. It incorporates interactive websites like Youtube with social media platforms like Instagram and Facebook. It is centralized through cloud services and corporate ownership.
Web3 consists of decentralized apps and services that run on the blockchain. These apps allow anyone to participate without monetizing their personal data. Further development of the concepts introduced with web2, web3 incorporates increased functionality and interactivity into web applications with the additional benefits of decentralization. Users in the web3 will have more freedom and flexibility compared with web2.
Web3 acts as a service on the internet. Anyone can use the service provided by the contract.
Web3 - "literally" .
Web2 and Web3 is really a battle of centralized services vs decentralized services. Google is a Centralized database web hosting platform. IPFS is a Decentralized Web hosting platform, but must be developed by open source developers and operated by you, the user.
Participants are connected to a central authority with a lot of computational resources wherein information propagates quickly.
Centralized is higher performance and easier to implement, whereas decentralized is the opposite.
Centralized has an easy way of confirming conflicting data's ultimate truth. When decentralized, a protocol is needed to dispute resolution.
Central provider vs rings and strings of providers passing on the provision to another .
Hackers could take down the centralized central authority, but a distributed Network can still function no matter if a large proportion of the network was taken out.
Centralized coordination is much easier, while Decentralized coordination is difficult. When there are disagreements on protocol changes, network is prone to fracturing.
Centralized authority can censor data. Censorship is harder when decentralized, since there are many ways for data to propagate across the network.
Centralized participation in the network is controlled by a central authority. Decentralized participation has no limitations. Anyone can participate.
We support the Decentralized internet of things, but web3 definitely has its own set of limitations. As it stands, it's advised that companies do not create business models that are fully reliant on the blockchain since decentralized service are not yet mainstream. The adoption of crypto currency is less than 1% of the total wealth on the planet.
Web3 developers chose to build dapps because of Ethereum's inherent decentralization:
Payment systems are built into solidity, the programming language designed by Ethereum.
No one can block you from this service. it's permission-less
Ethereum is turing-complete, meaning you can program anything you want into the web3.
It's the greatest innovation since the birth of the internet. Web3 represents digital identity, assets, property, law, or ownership of any kind- in a chaotic, yet beautiful way...
In our opinion, everything will eventually transition over to software vs hardware. Games will exist in the cloud, services will be completed 99% of the time online, money will be digital gold which is the instance of real gold and the remote economy will grow exponentially 📈
Scalability: Transactions on web3 are slower because of the fact they are decentralized. Changes need to be processed by a miner and then given out to everyone on the network. This can be solved using sharding, but ETH 2.0 has yet to be released.
UX: most interaction the user has with web3 applications require extra steps, software and education to master.
Cost: Most successful dapps put small portions of code on the blockchain since it's expensive to run full scrips. Memory collections are valuable to maintain. Data scientists, however, are far and few and cost a lot of money to hire.
Web3 tweets would be uncensorable whereas Web2 tweets can be censored by Twitter.
Web2 payments may decide not to allow certain credit cards to work. Web3 payments require no personal data and can't prevent payments from the wallet you use to pay with.
Web3 servers can't go down, since thousands of computers are used in their backend. Servers in Web2 could go down and affect worker income.
Blocks are batches of transactions with a hash of the previous block in the chain. This links blocks together in a chain because hashes are derived from block data. This prevents fraud since a change would invalidate the following blocks.
Blocks preserve transaction history of everyone's transaction; blocks and transactions are strictly ordered. Only in rare cases do participants on the network not agree on the exact number and history of the blocks.
Once a block is mined, it is propagated to the rest of the network. All nodes add this block to the end of their blockchain and then the mining continues. The exact block-assembly mining process is specified in the Ethereum's "Proof-of-Work" protocol.
Mining nodes have to spend a variable but substantial amount of energy, time, and computational power to produce a certificate of legitimacy for a block they propose to the network. This helps protect the network from spam or denial-of-service attacks.
Other miners hearing about the new block must accept the new block as a canonical next block.
Time needed to produce a certificate is random with high variance. This ensures no two people will create a block simultaneously, which would cause conflict.
Blocks consist of dozens or hundreds of transactions that are committed, agreed on, and synchronized all at once.
Spacing out commits gives network participants time to come to a consensus. Even though transaction requests occur dozens of times per second, blocks are committed once every 15 seconds.
Each block is finitely sized to avoid cramming the network with too many labor-intensive blocks.
Timestamp: Time when block was mined
Block number: Length of blockchain in blocks
Difficulty: effort required to mine the block
mixHash: unique identifier for that block
A parent hash: unique identifier for the block that came before
Transactions list: transactions included int he block
State root: Entire state of the system
account balanced, contract storage, contract code, and account nonces
Nonce: hash, when combined with the mixHash, proves that the block has gone through proof of work.
Preserving transaction history, blocks and transactions are strictly ordered. Only in rare cases do participants on the network not agree on the exact number and history of the blocks.
Once a block is mined, it is propagated to the rest of the network. All nodes add this block to the end of their blockchain and then the mining continues. The exact block-assembly mining process is specified in the Ethereum's "Proof-of-Work" protocol.
What if the blockchain is too big for a node to run, how do miner's computers keep track of the whole blockchain if their computers don't have enough storage as the blockchain grows?
Local or cloud storage. All networking solutions are involved. It's easier to troubleshoot and maintain a local node, but if you have issues with storage or maintaining the system, a cloud is useful → ie: Digital Ocean, Ankr, AWS
Blocks are the backbone of ₿itcoin, Ethereum and all other blockchain solutions that make the speed of the network more efficient. 👍 There are other blockchains that make it easier for these layer 1 blockchains to mine their transactions, called layer 2 solutions....
Consensus algorithms: it's when a bunch of computers work together (Chain) to be secure.
It would take 51% of the network to be attacked to bring down the blockchain, but the consensus algorithms make this nearly impossible since it requires a portion of the network to attack itself. There's no incentive to punch yourself in the face, so no one tries to do it.
The consensus's used are listed bellow.
miners process transactions, and they share their work on the EVM public ledger. Miners who solve the EVM crypto-puzzle and get the transaction approved is proof of work. In order to take down the network, 51% of all the miners would need to attack themselves and spend cryptocurrency (Ethereum) to disrupt their own network.
"POW" Prevents double spending, since POW checks the account balance before sending a transaction.
Having more miners make it easier to commit to the entire hyperledger.
they all have a block difficulty(3,324,092...), mixHash (0x...e64) and Nonce (0x...18)
when miners validate at the same time, this creates a fork
in the network. One fork will be longer than the other, making it the mother chain.
Finality time is important when designing your Dapps, since the user is going based off your version of the ledger. So it's recommended you make the finality time over a minute or every 6 blocks. This is better for the integrity of your applications.
To protect users from an attack, validators ("nodes" or "miners" in the scenario) put up their own money to run the validation algorithm. These validators are randomly chosen to create the new blocks, and they are rewarded for this, just like miners. No computation required, a simple stake of ETH is all you need, making the barrier to entry easier for people to enter into crypto. And if you decide to attack the network, your validator is " slashed " which refers to your node being blacklisted from the blockchain.
energy efficient | low barrier to entry | stronger decentralization
Forces validators to be on their best behavior, especially if they stake more; establishes a sense of trust.
attesting
- is a key term that means, "this block looks good to me". If validators Attest
malicious blocks, they lose their stake.
Sharded chains of 64 blocks interact with a beacon chain, which checks the shards of the single blockchain. The beacon
chooses the validator at random. 128 validators attest a single block which is known as the committee.
They have a slot
of time to propose the block, like their own schedule. 1 slot = 1 block. Much like a calendar, there are 32 slots in an epoch.
Once that epoch is finished, the whole network is disbanded and reformed to prevent malicious actors from attacking the network together. If your block has enough attestations, then it's cross linked
to the beacon chain and you get your juicy rewards.
Layer 2 solutions like the Harmony protocol have created their own blockchain and are interoperable with the Ethereum blockchain, meaning, they confirm block transactions using validators and speed up the mining process for miners, and they use their shard's to approve the transactions and send them to the Ethereum's EVM.
Layer 2 is a different network running on the top of the main Ethereum network or layer 1. The Ethereum layer 2 solutions stay on the Ethereum network in the form of smart contracts. ... Ethereum layer 2 scaling solutions could serve different functions such as off-chain computation and scalability of payments
Primary public distributed ledger. It's where all the price action occurs. This is the home for all DEX's, DAO's, Crypto Currency's, Dapp's and so much more!
Production environment that replicates the main-net features. analog vs stage. They use something called proof-of-authority. Gorli, kovan, Rinkebey, Ropsten. Lot's of developers use test-net to deploy applications before sending their Dapps to Main Net because once you deploy a Smart Contract, you cannot undo it.
You interact with these networks using a web3 wallet. these wallets let you transact over the internet instantly using the blockchain. the smart contracts you interact with will connect your wallet to the website, and if you decide to make a transaction, you will sign and pay the person who made the contract directly. No middle man required.
Download Here ; MetaMask Wallet for the Web3
☑️ MetaMask is how you will test net applications
☑ Test-Nets are private.
In the harmony wallet, you can choose which network you want to try.
There are faucets you can interact with to get fake Ethereum sent to your Test Net MetaMask Wallet.
Consortium networks**:** "If a public Ethereum network is like the public internet, you can think of a consortium network as a private intranet".
You will want to use a private Environment for your own development. Test networks are a great place to test applications. In our Getting Started section, you can find out how to set up a local blockchain environment in under an hour.
We mentioned this term called a smart contract, but you might be wondering how exactly these work. They're a mystery to many, yet have so much potential!
This is an entity with an ETH balance that can send transactions to other people. Accounts can be user-controlled or deployed as smart contracts. Interchangeable with wallets.
An account is not a wallet. ****
Wallet
- Is the private and public key associated with an account... which you will learn in a moment below. this will allow me to make any transaction I want. ****
What makes up a wallet?
Externally-owned – Controlled by anyone with the private keys
Contract – A smart contract deployed to the network, controlled by code.
nonce: It's transaction history
Balance : Amount of Ethereum that i own
Storage Hash: StorageRoot
SHA-3 algorithm which stores information of the account. A new tree hashing mode without extra overhead for small message sizes.
Code Hash : It's the code of the Account. It's like the parameters of the account, and when ever it's called to action, it takes action. this code hash can never change either, and is permanently stored in the cloud. Any externally owned Code hash is just an empty string
In other words, when you see crypto currency in your wallet, you are seeing the amount that is associated with the amount of crypto you carry. You never own the crypto your address carries. It simple reserves the hash in your account key, and you "own" it in various ways. We'll explain all the account types as we continue reading.
You never hold cryptocurrency, you really only ever hold a super private key and this key unlocks the ether ledger which grants you access to your funds.
Ethereum has 2 account types
Externally-owned: controlled by anyone with private keys.
Contracts: Smart contract deployed to network, controlled by code.
Both account types can:
Receive, hold, and send ETH and tokens
Interact with deployed smart contracts
Externally-owned
Creating an account is free 🆓
Initiate transactions
Transactions between accounts can only be ETH transfers.
Contract
Creating a contract has a cost because you're using network storage.
Can only send transactions in response to receiving a transaction.
Transactions from an external to contract account can trigger code which can execute different actions, such as transferring tokens or even creating a new contract.
Ethereum have four fields:
nonce: this is a counter that measures the number of transactions sent from the account. This number represents the number of contracts created by the account.
balance: number of wei owned by this address. Wei is a denomination of ETH. There are 1E18 wei per ETH.
codeHash: This is the code of an account.
storageRoot: This encodes the storage of an account.
What an account is. - > https://ethereum.org/en/developers/docs/accounts/ Essentially, the accounts do no own the money you have. Think of it like a house address... you own the house, but you don't own the address or the area code. or the zip code.
Public key: This can prove that someone originally initiated the transaction request.
Private key: Sign transactions
This prevents fake transactions from taking place since the sender can always be verified.
Creating an account generates a random private key.
1 private key is made of 64 hex characters that can be encrypted with a password
You can make new public keys with the private key.
You can't make private keys from public keys.
The private key is necessary to sign messages and transactions.
Others can take the signature to derive your public key.
This proves the author of the message.
Contract accounts have a 42 character hexadecimal address
This is given when the contract is deployed to the Ethereum Blockchain.
The address comes from the creator's address and the number of transactions sent from there
Contract account example
slightly different. They have 42 hexes. this is minted based on my account address + the number of transactions from my account's address. So, the Nonce - the transaction history.
An account is not a wallet.
Wallet is keypair associated with a user-owned account.
Smart Contracts : These are accounts. These accounts define the rules of the contract and are done automatically. Solidity and Vyper
or Yul+
, or Fe
are fairly new programming languages that develop these vending machines. Solidity is an Object Oriented Smart contract language; it's a curly - bracket, statically typed language that has object inheritance, libraries that work with all languages and has its own defined types, functions and unique syntax.
Consider where the data will live, because it's costly to change data in the contract after you launch it. When contracts compile, they need to have a set unit of storage. Theaddress
variable type stores 20 or 160 bits.
You can call other smart contracts in your own smart contract to greatly extend what's possible. Contracts can even deploy other contracts!
They can't send HTTP requests, so they can't pull data from the internet, but they can use an Oracle
to get around that problem.
There are internal (don't call) and external (do call) function calls, calling in or out the contract. Public and Private - work in the same way. getter
functions work like OOP, and the new
keyword can even make new contracts. The code to sending ethereum uses calls
, and stoping transactions uses selfdestruct
.
constructors
are used only once to initialize state variables. Some things you won't need to construct, since built-in functions exist, like address.send()
When you have a front end application, the app can create an event
, that transits data to be logged
to the blockchain.
functions
have modifiers
- best way to explain this, is bat man having robin helping out.
solidity logo
The programs uploaded by application developers and users that make requests for execution of code snippets are smart contracts. Smart contracts manifest as an account on the Ethereum network and execute transactions based on the parties on both sides of it. It is like a vending machine that creates and assigns ownership of cryptocurrency if the caller sends ether to a recipient. Smart contracts made by developers and smart contracts called by a user are done so with a fee paid to the network. Developers can make marketplaces, financial instruments, games and so much more with a smart contract.
Smart contracts are public on Ethereum and can be thought of as open APIs. You don't need to write your own smart contract to become a Dapp developer, you just need to know how to interact with them*. For example, you can use the existing smart contracts of Uniswap, a decentralized exchange, to handle all the token swap logic in your app – you don't need to start from scratch.*
If you've programmed before, you will know that all programs require either an interpreter or a compiler to execute your code. See, solidity must be compiled first before it is executed or deployed to the blockchain. Similar to any other Object Oriented Programming Language. You will learn more in the upcoming lessons.
You need front and Backend languages to develop your application. You will need package managers to store your code. The code you write will be framed inside your IDE, and you will need to port your Dapp to a node that's connected manually or in the cloud to the blockchain. You must make sure to test and run your application's contracts locally before deployment. Remember, contracts are a one and done thing. once you deploy, you cannot reverse your smart contract's information.
mongodb-replicaset.webp
💡 EVM
will turn the smart contract's code, into byte code. This byte code is not human readable. This byte code is known as ABI
, or application binary interface → which essentially allows your app to make sense of the contract you wrote. It reads the bite code, compiling the smart contract for you within the contract itself.
Meaning, the code you write can execute on its own, making smart contracts have this automatic nature to them.
ABI
is the instruction list for the app, with how it interacts with your smart contract. It happens automatically.
💡 Clean up, deploy and interact with your contracts doing project based learning to become more familiar with how programming in solidity works.
💡 💡 The ABI is a JSON file, this is what allows your dapp to interact with Web3.js
💡 💡💡 To deploy, you need 1) Ethereum 2) Byte code from the compiled contract 3) A script that plugs-in too an Alchemy / Infura node || or your own node. Once deployed, it will have an address. To keep track of the contracts performance metrics, go here >>> Tenderly.com
💡 💡💡 💡 Consider running the contract on a node provider like Geth, Open Ethereum, or Nether mind
💡 💡💡 💡💡 You have the option to launch your own local blockchain inside a frame to work in, like Truffle, Hardhat, Brownie, Embark, Web3j, OpenZeppelin SDK, Create Eth App, Scaffold-Eth, The Graph, Alchemy, Etherlime
Python Deployment kit. the same thing exists for other languages.
if you're coding you need to make sure you code won't get hacked.
Defisafety.com and consensys.github.io repository has good information on how to protect your self from cyber attacks in DeFi { Decentralized Finance }
It's 2021 - and Ethereum and all things crypto is considered the wild west of the internet. Lot's of hackers acting as DeFi cowboys stealing and taking names without ransom. On August 9th, 2021 The cross-chain protocol Poly Networkt suffered a cyber attack that drained multiple blockchains of their Ethereum, costing their network $611 million worth of ETH.
→ An audit at the end of writing your smart contract is no longer sufficient as the only security consideration your project makes. Security starts before you write your first line of smart contract code, security starts with proper design and development processes. Open source contract security can be followed using the openzeppelin
standards.
The cryptographic proof that makes validates the Ethereum blockchain, is using the Merkle tree algorithm.
A Merkle tree is a hash-based data structure that is a generalization of the hash
list. It is a tree structure in which each leaf node is a hash of a block of data, and each non-leaf node is a hash of its children. Typically, Merkle trees have a branching factor of 2, meaning that each node has up to 2 children.
https://eth.wiki/fundamentals/patricia-tree - . Learn more about the crypto tree here.
What is Hashing? Hash Functions Explained Simply
Hashes
are one-way functions which map arbitrary text into fixed values called hash values. they are cryptographically secure as well as impossible to predict. Each successive Block in a blockchain adds the previous hash of all the transactions in the previous block to the current transactions to make a new hash value for the block, signifying its own unique identifier, to maintain the state of the blockchain.
The first time we ever heard the word Canonical, was when we read the Ethereum documentation. It can refer to something reduced to its most basic form ; it follows a principle or rule. Rules like the Merkle tree and the Eliptical curve algorithm and other data structures are created from the ground up. It starts with a math equation, and then it transitions over to an assembly language which builds everything from foundation. First Principle thinking: The act of boiling a process down to the fundamental parts that you know are true and building up from there.
The foundation of code and all computer speak, starts with a 0 and a 1.
QUESTION
bit's are 0's and 1's, and when you put them together, they are a binary. They store information!
A byte, is 8 of these little bits.
Imagine a light switch; Given a Zero or a One, can you guess which one is on or off? Zero, or One?
That's right! 1 is on, 0 is off.
Knowing how memory, stacks and bytes all work together will help make coding for the EVM easier to for you as you continue to learn. That is the whole purpose of this lesson!
You DO NOT need to force yourself to memorize these tables.
Integral Data Types here STORE information in the best way using these types in your code
Binary In python
Don't worry if you don't understand.. do your best to recognize the number paterns... you will make sense of it.
Each block is added every 12 seconds to Ethereum.. and thousands of pieces of data exist in each block. here's what they consist of →
The blockchain is like a map, of directions with many different roads, each with their own labels. The block, is like a quest that miners must journey to prepare for. They must have the resources to mine the block, and their efforts are recorded on the ledger, which is like a map of the worlds work and their entire journey in the blockchain.
Block Height
is the block number == length of the blockchain, which comes with thetimestamp
which is the time the block was created. TheTransaction
number is in that block too, and the address of theminer
who mined that block and theirreward
for mining it. There is adifficulty
associated on the explorer, which is dependent on thesize
of the block == the data of the whole block. And if it's big, then it also has thegas used
amount, and where eachgas limit
was for each transaction.Extra data,
from miner to audience, is included. Every block has a name, which is the header, called thehash
. The block before the current has, is theparent hash
, like how our parents came before us. All parents have uncle blocks, which are transactions mined at the same time, and their combination of names is calledSah3Hash
. TheStateHash
is the root name of the entire system that these blocks work in, and for each miner's work, that work is proven by thenonce
, the proof-of-work by the miner. Block Explorers will detail out thegas
prices and usage on each individual using the network too.
Block explorers allow you to verify the sender.
🗝 check our crypto wallet here : one14pnf2xvnly9qduhjw8u58xdmtuz9mr3jdmwcp8
🔑
check here →
The public key is connected to a private key whenever we sign a transaction. This prevents someone from taking our public key and making a transaction on our behalf. This can never happen because that malicious actor would need our private key.
What does a private key look like? It's something you get whenever you make a crypto wallet like a trustWallet, Meta Mask or OneWallet on your desktop or browser (similar to a google plugin)
This is an example of a private key. 64 hex characters long!!! it's encrypted with your own password that you know never tell anyone 🤫
computers are not super precise. "they suck at math". Floats and integers can represent certain computations. Memory can only hold a certain amount of information. Taking a fixed size, and expanding it to a greater level. Represent a floating point without loosing the value of the float itself. It's a positional numeric! We use this in the Caribic numeral system that is also positional.. like the 100th's place, 10th's 1s' etc... Roman numerals are not positional. Big-Nums are special type of positional. Binary works the same way, 1, 2 place 3 place... How do they work? chaining together integers. an array is a simple way of putting it. Each element is 1 digital. The big num is the maximum. Each time the last element fills up, the next one starts + Tree's / Heaps - Big Num is just a big ass number.
the Public Key is generated from the private key
This is an example of what public keys look like after they are generated. You can never get a private key from a public key. ever.
elliptic curve digital signature algorithm - at a security level of 80 bits—meaning an attacker requires a maximum of about $2^80$ operations to find the private key. that's 1.2(24 zeros) ... you would need every super computer on the planet to break that encryption. it's nearly impossible.
Javascript
(Another programming language) can be used to send transactions to the network using your private key which encrypts it as your signature and then retrieves your public key and provides a transaction.
API vs TOKEN : The main distinction between these two is: API keys identify the calling project — the application or site — making the call to an API. Authentication tokens identify a user — the person — that is using the app or site.
Transaction objects need to be signed by your (sender's) private key.
recipient: Receiving address.
Externally-owned account: value is transferred
Contract account: transaction will execute the contract code.
Signature
Identifier of the sender
Generated when sender's private key signs and confirms sender has authorized the transaction.
value
Amount of ETH sent
data
field for including arbitrary data
gasLimit
Maximum gas units consumed by transaction. Units of gas represent computational steps.
gasPrice
fee paid per unit of gas
Process
You send a transaction! it gets turned into a 0x64-hexadecimal; it jumps into a giant swimming pool of transactions (mempool
); then a state
miner comes along and jumps into the pool and verifies that you're successfully in the pool with them. The higher the gas price
you paid to get into the poo, the faster you get to come out of the pool. In other words, the more you pay to jump into the mempool, the more desirable the transaction will be to the network of nodes.
Miners Want Gold, didn't you know that?
Simply put, it's managed by a human, not by the contract. it's no different than debit purchases. it deducts money from my account and adds it to the person I'm sending money (tokens) to.
"giving someone money"
if I give someone money, it's like the whole network of nodes
on the EVM
know I did it. Remember the block explorer I showed you.
Cryptographically signed instructions from accounts. Account will initiate a transaction to update the state of the Ethereum network. The simplest transaction is transferring one ETH to another.
https://ethereum.org/en/developers/docs/accounts/
https://ethereum.org/en/developers/docs/intro-to-ethereum/
... An Ethereum transaction refers to an action initiated by an externally-owned account. Debiting for the sender and crediting for the receiver of an ETH has to occur. The state-changing action takes place within a transaction.
Transactions are broadcasted through the whole network. Any node can broadcast a request. A miner then has to execute the transaction. Transactions require it to be mined to become valid. Transaction will get a block confirmation number. This is the number of blocks created since the block that your transaction was included in. A higher number means there is more certainty that the transaction was processed and recognized.
a Blockchain transaction is similar to a receipt you get from the store; here are the parts of a transaction.
Gas is a reference to the computation required to process transaction by a miner. Users pay a fee for it. gasLimit
and gasPrice
determine maximum fee amount.
raw
is signed transaction in RLP
(Recursive Length Prefix) form encoded from the tx
tx is signed transaction in JSON form
Signature hash
is where transaction can be proven it came from sender.
You need to pay a fee to send transactions and to use the computing power of the blockchain. This is what gas is known as, and it's what makes Ethereum the electricity provider of the blockchain.
21,000 units of Gas are needed for a simple transfer transaction.
0.000000001 ether == 1 gwei ; the denomination of gas for ethereum.
Why are we paying a fee? - Helps secure the network because a fee restricts spammers from attacking the network. Even the transaction requires a step's limit for computation → "gas"
Simple transactions cost 21,000 gwei
( gas price)
gasPrice and gasLimit determine maximum fee amount
Signature hash
is meant to prove that the transaction coming from a sender.
smart contracts
cost more gas since they require a lot of code to be recorded on the blockchain.
You can track gas prices
Keep track of the blockchain gas prices.
If it costs 21k gwei to send eth, and you send 50k gwei to send it, you will get back 29k gwei... But warning ⚠️ if you send 20k gwei, you will lose the fee and your transaction will not send. Best Strategy : "Always make sure you have enough gas to get to your destination"
All Dapps have to connect to an Ethereum node
. JSON-RPC API endpoints can be used to fetch data
In perspective *: I can use a JSON or backend NODE requests to make my life easier in any programming language I want to write my contract in. Javascript knows how to interact with my Solidity code, depending on the language Framework I intend to use (web3.js →Ethers.js → javascript, web3.py→ python, web3j → java).
The request will pull information from the contract and Javascript will read my contract and know how to interact with my web2/web3 application.
There's no easy way to describe this...
In other words → "Javascript will read any contract either from your house or someone else's house and tell your computer what to do.
Using a node as a service might be your best option if you don't have the time to optimize your node *
Check more on JSON calls here → HERE*
Some JSON methods require data.Gossip
(These methods track the head of the chain), State
(current state of all the data stored), and History
(every block back to genesis. This is like one large append-only file) → you can find all JSON Methods here →→>>>HERE
You're almost finished. The Question then becomes, how does this connect to the real world. We mentions Oracles before, and now we are going to dive deeper into what these are. Some would say, it's the centralized aspect to the decentralized web. People don't like that it exists because it relies on centralization to bring data from the real world into the blockchain. I would argue that there are very positive use cases for oracles. You might be able to imagine some of your own...
Oracles Are the bridge between the real world and the blockchain. They can transit data like weather reports or sports data; anything into the contract.
Much like BoGani's game Star Walkers, this game pulls data from the real world of astrology, into the NFT game for the on-chain performance stats that each card has when minting the character.
Oracles post data about the blockchain. it's a combo of smart contracts and api's. These API's
secure themselves using a feed system, like the Maker DAO's to get price feeds
" Feed system", from all over the blockchain.
Emit a log with the contract's event, have someone like Alchemy.com cite these events by logging them; Alchemy services the user by doing what it does to log data, then it sends the data back in another transaction to the smart contract.
IF users don't want a million transactions happening between the oracle and the contract, you can compile a bunch of API calls off chain, and then have them submit one transaction to lessen the gas fee's. this is called Chainlink OCR
Congrats you finished!! Lesson 0
This section is not necessary to put into practice since most of the information about nodes is all over the internet. We would need to make a whole separate lesson about nodes to get you set up. For now, you can review the basics and come back to this later once you're ready to deploy your first application.
This section is not necessary to memorize or learn unless you are planning on developing applications at home, using your own server or another cloud based server; if so continue researching.
Lesson%200%202fe406888d99411b9b8c174b15cabdc2/amazon_polly_54318.mp3
a node
is a client software running on peoples computer that is mining for the EVM
Client : In computing, a client is a piece of computer hardware or software that accesses a service made available by a server as part of the client–server model of computer networks. The server is often (but not always) on another computer system, in which case the client accesses the service by way of a network
A node
is the computer that is running to approve all the transactions on Ethereum 👍
All nodes run on many programming languages, and they follow these set of rules → Ethereum Yellow Paper.
Yellow paper for ethereum. you may read this to set up a node.
This is a diagram of how the client model works, a simplified version of the yellow Paper. PoW means Proof of Work; The MemPool is that giant swimming pool of transactions, and the State is deciding which offer they want in the pool, usually the largest $$$ amount. Then it uses the Virtual machine and it pumps out the results to the person receiving that transaction in a p2p (peer to peer, from me to you) model. It's a super vending machine!!!
🤩 Full Node = Stores the entire blockchain and the data, participates in the mining, is a source for other nodes, and provides information / data on request.
😳 Light Node = stores only the header of an account
, makes requests to Full nodes, and it's used on mobile applications : best because you can store the whole blockchain on a little phone.
👽 Archive Node = Mothership of full nodes
! great for keeping track of every balance from every block ever created. Terra bytes large. Huge data providers.
Secures and provides greater control of the applications that you send to the blockchain.
you can learn how to make a node here →
Spin up your own Ethereum node | ethereum.org
These node sections are not necessary to understand unless you plan on developing for layer two solutions. Running a node is important if you want to own your own Dapp. It's similar to running your own server for a discord, or a game lobby.
Cloud Node providers : https://www.quicknode.com/
Buy the hardware to run your node : https://ava.do/
HOW TO TURN YOUR RASPBERRY PI 4 INTO A NODE JUST BY FLASHING THE MICROSD CARD
How to turn your Raspberry Pi 4 into a node just by flashing the MicroSD card | ethereum.org
Fun personal project anyone can work on
Run a node on geth Tutorial
How to run a light node with Geth | ethereum.org
These are more intermediate knowings. We should definitely have a breakdown of a node set up once this project is finished.
NODE can be used on any Operating System.
First, download the right cloud provider software; ie → GETH
https://geth.ethereum.org/downloads/
If you click on this, you will download it. Just visit the site instead if you dont want to download it. https://geth.ethereum.org/downloads/
Make sure you have the right amount of disk Space available ✔️ you have nothing clogging your memory, and the Operating system is Up to Date 😁 this sounds weird, but your timezone on the CPU has to be accurate.
Your router and firewall accept connections on listening ports. By default Ethereum clients use a listener (TCP) port and a discovery (UDP) port, both on 30303 by default.
Now test it using the geth light node, which is provided in the walkthrough above
Remote Procedure Call - You would figure out how to use the client on your computer with any given language listed in this document →https://eth.wiki/json-rpc/API and then you would use it by learning how to interact with it on the web3 → https://metamask.zendesk.com/hc/en-us/articles/360015290012-Using-a-Local-Node
Stay secured, using a private connection to not flag your IP → https://www.torproject.org/ ; which then the RPC (remote Procedure Call) can connect too.
Keep in mind
If you're using the node to be a wallet, be careful and use an Hidden IP. If your staking, we don't recommend shutting it down. It takes awhile to re-sync to the network after it's turned off.
Ethereum Improvement Proposals: it can be used to update the clients, which is how ERC-20 and ERC-721 were implemented to make NFT's, which forces the state of token security to be the same across all transactions. →
Allows you to use Layer two solutions, which aren't operational yet on Ethereum 2.0 yet, but Harmony Protocol is a layer two solution which you can run your node on. →
Create a database for your node in prometheus then create visual charts with Granfana.
Now we're talking business. Using nodes as a service provider is easy and can be done with 1 code line to switch between services.
some node clients
and types
(full, light, archive)
DO NOT EVER STORE PRIVATE KEYS on these service nodes.
using service nodes allows you to focus on your product vs the maintenance of the node. The bandwidth can be expensive, and the time spent on the node is invaluable.
service nodes are centralized. If you don't believe in that, run your own.
privacy running your own node is easier.
Managed blockchain services | Chainstack
GetBlock - blockchain nodes provider. Get access to full nodes with us | GetBlock.io
Ethereum API | IPFS API & Gateway | ETH Nodes as a Service | Infura
Moralis - Build Serverless Web3 Apps
QuickNode - Hosted Ethereum, Polygon, Optimism, Bitcoin, Fantom, BSC & xDai Nodes
The best blockchain gateway on 🌎
A guide for the barely motivated ;) - this Will help. you can also use Nethermind
Rasberry Pi tutorial → 🍰 "fun project on mini computer"
node set up → 👾 "super easy"
Experienced users → 🙌 "miners who run nodes"
Sharding is when you store data in multiple machines. Sharding is useful because it's a lot faster to store your data in multiple machines than to store in one single machine. Nodes are broken up into smaller groups through sharding. Transactions are not done on every single machine, but on smaller groups without sacrificing security