Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn ethereum

Scale Ethereum Blockchain technology

 1. Goal of scalability Reduce the cost of using the network (blockchain has reached certain capacity limitations). Increase transaction speed (faster finality), and transaction throughput (high transactions per second), without sacrificing decentralization or security. 2. Two main solution to scale Ethereum blockchain 👉 ON-CHAIN SCALING (Sharding):  Requires changes to the Ethereum protocol (Mainnet - layer 1). Splitting the blockchain into discrete pieces (shards) to be verified by subsets of validators. 👉 OFF-CHAIN SCALING: Layer 2 scaling : derives its security and handling transactions off from Mainnet Ethereum, centered around a server or cluster of servers (referred to as a node, validator...) Transactions are rolled up into a single transaction to Mainnet Ethereum. it's two types of rollups with different security models:  Optimistic rollups and Zero-knowledge rollups. State channels : use multisig contracts to enable participants to transact quickly and freely off

Compare Assert and Require

  Require Assert to check input arguments from users. to check internal states that should never happen to check invariants and it evaluates to false: all remaining gas is returned. to check invariants and it evaluates to false: all gas is consumed.

Ethereum: The Difference between function transfer fund in Solidity.

Address.transfer() Address.send() Address.call.value() Address.delegatecall() Stipend of  2300  gas along. Stipend of  2300  gas along. All gas will be sent along.   Used to  transfer funds  out of a smart contract to “someAddress”. Used to  transfer funds  out of a smart contract to “someAddress”. Interact and send ether  to the “Address”. Which uses the scope of the  current calling contract  and is mostly  used for libraries . Which is a  high-level function , there is an exception happening during the transfer, it  cascading exceptions . Low-level function , there is an exception happening during the transfer, it  returns “false”. Low-level function , there is an exception happening during the transfer, it  returns “false”. Low-level function , there is an exception happening during the transfer, it  returns “false”. Safe against re-entrancy  because they send only the gas-stipend of 2300 gas along. Safe against re-entrancy  because they send o

Difference between Ganache and Truffle

  Ganache Truffle allows you to create a private Ethereum block chain for you to run tests, execute commands, and inspect state while controlling how the chain operates. It gives you the ability to perform all actions you would on the main chain without the cost. Many developers use this to test their smart contracts during development. It provides convenient tools such as advanced mining controls and a built-in block explorer. a developer environment, testing framework and asset pipeline for block chains. It allows developers to spin up a smart contract project at the click of a button and provides you with a project structure, files, and directories that make deployment and testing much easier (or else you would have to configure these yourself). Ganache is a little different, in that it is attempting to mimic the main network. There are a few problems here: There are no miners on Ganache. Because of this, yo

Ethereum: Smart contract

6 Characteristic of Smart contract: 👉 A program that runs on the Ethereum blockchain (mainly developed by friendly languages: Solidity or Vyper).  Cannot be deleted, irreversible.  Deploying into main net need pay gas (must be compiled before). 👉 Have a Balance + can send transactions over the network (as a type of Ethereum account). 👉 Define rules (like a regular contract) and automatically enforce them via the code. 👉 Can call other smart contracts in your own smart contract. Can't send HTTP requests to get information about "real-world". 👉Maximum of 24KB ( refer diamond pattern: https://eips.ethereum.org/EIPS/eip-2535 Standard for creating modular smart contract systems ). 👉 Could be require multiple valid signatures to execute a transaction (Avoiding single points of failure for contracts holding substantial amounts of ether or other token). It r equires N signatures out of M possible acceptable signatures (where N ≤ M, and M > 1). Example: With N = 3, M =

Ethereum: Proof of stake (PoS)

Proof-of-stake is a type of consensus mechanism used by blockchains to achieve distributed consensus. Within that, v alidator is then responsible for checking that new blocks propagated over the network are valid and occasionally creating and propagating new blocks themselves. 👉 VALIDATORS Must deposit 32 ETH into the deposit contract  Run three separate pieces of software: an execution client, a consensus client, and a validator. Validators receive new blocks from peers on the Ethereum network --> The transactions delivered in the block are re-executed, and the block signature is checked to ensure the block is valid --->  sends a vote (called an attestation) in favor of that block across the network. Time in proof-of-stake Ethereum is divided into slots (12 seconds) and epochs (32 slots).  Randomly selected to be a block proposer in every slot. 👉   FINALITY Using "checkpoint" blocks which first block in each epoch. 👉   CRYPTO-ECONOMIC SECURITY Validator is paid i

Ethereum: proof-of-work (POW)

Proof-of-work (POW) : is the mechanism that allows the decentralized Ethereum network to come to consensus and ensure Ethereum difficult to attack.  Example about Consensus: Account balances. O rder of transactions. 💧 The work in proof-of-work 👉   Step 1:  miner will repeatedly put a dataset which get from downloading and running the full chain through a mathematical  (--> what in fact behavior to get dataset??) 👉   Step 2: dataset gets used to generate a mixHash below a target nonce, as dictated by the block difficulty. (--> How to generate mixhash and nonce from dataset) 👉   Step 3: other miners and clients to verify  (--> how to verify that nonce and mixhash are correct?) Note : explain detail how POW works: https://youtu.be/9V1bipPkCTU 💧   Proof-of-work and security Because a malicious miner can not solve the block nonce faster than everyone else, so it's nearly impossible to: Create new blocks that erase transactions,  Create fake ones,  Or maintain a second ch

Ethereum: Account

2 Ethereum account type 1. External account Controlled by anyone with the private key which use to sign transactions. An account is made up of a cryptographic pair of keys: public and private .   Public key is generated from the private key using the Elliptic Curve Digital Signature Algorithm .  Public key prove that she originally initiated the transaction request.  It is possible to derive new public keys from your private key but you cannot derive a private key from public keys.  Costs nothing. Can initiate transactions. Transactions between externally-owned accounts can only be ETH/token transfers. 2. Contract account Controlled by code.  H as a cost because you're using network storage. Can only send transactions in response to receiving a transaction. Transactions from an external account to a contract account can trigger code which can execute many different actions . 👉  Both account can : Receive, hold and send ETH and tokens. Interact with deployed smart contracts. 3

Ethereum: Token standard

  4 Main Ethereum token standards.

Ethereum: Denominations

Unit Wei Value Wei wei 1 wei 1 Kwei (babbage) 1e3 wei 1,000 Mwei (lovelace) 1e6 wei 1,000,000 Gwei (shannon) 1e9 wei 1,000,000,000 microether (szabo) 1e12 wei 1,000,000,000,000 milliether (finney) 1e15 wei 1,000,000,000,000,000 ether 1e18 wei 1,000,000,000,000,000,000

Ethereum: Blocks

 Blocks are batches of transactions with a hash of the previous block in the chain. 1. HOW BLOCKS WORK Strictly ordered: every new block created contains a reference to its parent block) and transactions within blocks are strictly ordered too. Once a block is put together (mined), all nodes add this block to the end of their blockchain. 2. WHAT'S IN A BLOCK? timestamp – the time when the block was mined. blockNumber – the length of the blockchain in blocks. baseFeePerGas - the minimum fee per gas required for a transaction to be included in the block. difficulty – the effort required to mine the block. mixHash – a unique identifier for that block. parentHash – the unique identifier for the block that came before (this is how blocks are linked in a chain). transactions – the transactions included in the block. stateRoot – the entire state of the system: account balances, contract storage, contract code and account nonce are inside. nonce – a hash that, when combined with the mixHa

Ethereum: Network

Ethereum networks with: 💧 PUBLIC NETWORKS Accessible to anyone in the world with an internet connection. They can read or create transactions on a public blockchain and validate the transactions being executed. Where: 👉Mainnet: Actual-value transactions occur on the distributed ledger. For exchanges ETH  👉Testnets Like environment before deployment to Mainnet. Most testnets use a proof-of-authority consensus mechanism. Most people get testnet ETH from faucets.  💧 PRIVATE NETWORKS 👉Development networks Can create a local blockchain instance to test your dapp.  Much faster iteration than a public testnet. 👉Consortium networks Participating must be equally involved in the consensus and the decision-making processes of the chain.

Ethereum: Node and Client

Ethereum is a distributed network of computers running software known as nodes which verifies all transactions in each block, keeping the network secure and the data accurate. 👉 03 Ethereum node type Archive node : Stores everything kept in the full node and builds an archive of historical states . So it can be handy for services like block explorers, wallet vendors, and chain analytics. Full node : Stores full blockchain data . it verifies all blocks and states . Light node : Stores the header chain and requests everything else. verify the validity of the data against the state roots in the block headers. Useful for low capacity devices. 1. Why need to run yourself Ethereum  node (?) 👉Benefits to you : Can verify the data yourself with your client. Won't have to leak your addresses and balances to random nodes. You can connect to your node using Inter-process Communications (IPC) or rewrite the node to load your program as a plugin. 👉Network benefits L ight nodes can reque