DApps and Smart Contracts

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In the context of DApps, what is the primary role of state management?

  • Optimizing the application's performance on different devices
  • Securing the application from external threats
  • Controlling the user interface of the application
  • Managing the data and the current status of the application (correct)

What is a key characteristic of Distributed Applications (DApps) that distinguishes them from traditional applications?

  • They are developed using a single programming language.
  • They run on a distributed P2P network rather than a single computer. (correct)
  • They have a centralized authority that controls the application's functionality.
  • They are not capable of interacting with a frontend web interface.

In the 'money.sol' smart contract example, what would be the expected outcome when the Withdraw() function is called after depositing 60?

  • The function will return 60, representing the originally desposited amount.
  • The function will return 120, calculated as twice the deposited amount. (correct)
  • The function will fail due to insufficient gas.
  • The function will return 0, as the withdrawal function is not properly implemented.

Why is it necessary to copy the contract address and ABI for frontend development when working with smart contracts?

<p>To enable the frontend to interact with the deployed smart contract by knowing its address and functions. (A)</p> Signup and view all the answers

What purpose does the Goerli testnet serve in the context of DApp development and deployment?

<p>It provides a testing environment for deploying and testing smart contracts before deploying them on the mainnet. (A)</p> Signup and view all the answers

What is the core concept behind IPFS that aims to improve upon HTTP?

<p>Content-addressed system (D)</p> Signup and view all the answers

What is the role of a Distributed Hash Table (DHT) in IPFS?

<p>To locate nodes in the network that possess specific data, using a hash of the content. (D)</p> Signup and view all the answers

What is the primary purpose of a Merkle DAG in the context of IPFS?

<p>To enable content addressing and tamper resistance. (D)</p> Signup and view all the answers

What is a key advantage of using IPFS over traditional HTTP when accessing files?

<p>IPFS allows access to files even if the original server is offline because the content is distributed across multiple nodes. (A)</p> Signup and view all the answers

What is the main vision behind the concept of a Decentralized Autonomous Organization (DAO)?

<p>An organization with no management structure, board of directors, or employees. (C)</p> Signup and view all the answers

Why was The DAO considered stateless?

<p>Because it was not tied to any country, making its regulation ambiguous. (B)</p> Signup and view all the answers

What critical flaw was exploited in The DAO, leading to a significant loss of funds?

<p>A bug, known as the Reentrancy Bug, in the order of code execution. (C)</p> Signup and view all the answers

What was the primary purpose of the hard fork implemented after The DAO attack?

<p>To rewrite the history of the blockchain, returning stolen funds. (A)</p> Signup and view all the answers

What is the key difference between a hard fork and a soft fork in a blockchain network?

<p>A hard fork requires all nodes to upgrade to the new rules, potentially creating a new chain, while a soft fork is backward compatible with previous versions. (C)</p> Signup and view all the answers

Following The DAO incident, what was one of the key lessons learned regarding smart contracts?

<p>Smart contracts require rigorous auditing and testing, as they cannot be easily corrected once deployed. (D)</p> Signup and view all the answers

What is the initial step in developing a DApp as described in the lecture?

<p>Writing the <code>money.sol</code> contract. (D)</p> Signup and view all the answers

What is the purpose behind testing the functionality on Remix IDE during DApp development?

<p>To ensure the smart contract functions as expected before deployment on a test network. (D)</p> Signup and view all the answers

Why is Metamask Wallet used during the integration and deployment phase of a DApp?

<p>To manage the deployment of the smart contract on a test network. (D)</p> Signup and view all the answers

In the context of IPFS, what does content addressing ensure?

<p>Content is accessed based on its unique hash, regardless of where it is stored. (C)</p> Signup and view all the answers

What is the main goal of IPFS in relation to the traditional client-server model of the web?

<p>To create a peer-to-peer distributed file system that reduces reliance on central servers. (A)</p> Signup and view all the answers

Which of the following is a key characteristic of the DAO's original code that contributed to its vulnerability?

<p>The code had two lines in the wrong order, allowing repeated withdrawal of ether before the check. (B)</p> Signup and view all the answers

What immediate action followed the discovery of the vulnerability in The DAO, primarily driven by the community?

<p>A community debate about whether to rewrite history by hard forking. (D)</p> Signup and view all the answers

What fundamental property of blockchain technology was challenged by the hard fork that addressed The DAO incident?

<p>Immutability. (D)</p> Signup and view all the answers

How does the IPFS address the issue of broken links associated with HTTP?

<p>By using content-addressed system so that every file's representation is done by integrating a hash. (A)</p> Signup and view all the answers

Which feature of Smart Contracts allows it to automatically control blockchain transaction and investments?

<p>Code. (C)</p> Signup and view all the answers

Following the hardfork, which characteristic of blockchain was affected?

<p>Immutability. (D)</p> Signup and view all the answers

After a hard fork in July 20, 2016, what event occured?

<p>RHG now needs to return 70% of the ETC to the original investors (C)</p> Signup and view all the answers

What is stateless DAO?

<p>Not tied to any country. (C)</p> Signup and view all the answers

Flashcards

What are Distributed Applications (DApps)?

Software applications that run on a distributed peer-to-peer network, rather than a single computer.

What is InterPlanetary File System (IPFS)?

Peer-to-peer distributed file system that stores files and tracks all transactions on the distributed network.

What type of system does IPFS use?

A system where every user in the network holds a portion of the overall data, creating a resilient system for storage and sharing.

What is HTTP?

A protocol in which a web browser sends a request to an external server, which returns a response message.

Signup and view all the flashcards

How does IPFS address HTTP problems?

Guarantees a permanent and distributed web by incorporating content-addressed system instead of location-based system.

Signup and view all the flashcards

What is content addressing in IPFS?

Unique identification of content.

Signup and view all the flashcards

What was the purpose of The DAO?

Venture Capital Fund for blockchain based investments that would be directed by investors (owners of the DAO token).

Signup and view all the flashcards

What caused The DAO attack?

Allows withdrawal of ether repeatedly before checking if the attacker was entitled to withdraw.

Signup and view all the flashcards

What is a Hard Fork?

A major software change that is not backward compatible with previous versions, requiring nodes to follow new rules for consensus.

Signup and view all the flashcards

What is a Soft Fork?

A relatively minor software change that is backward compatible with previous versions, not requiring nodes to upgrade to form consensus.

Signup and view all the flashcards

Study Notes

DApps Lecture Notes

  • Distributed applications (DApps) are software applications that run on a distributed P2P network rather than a single computer.
  • These interact with a Frontend Web3.

Smart Contract: "money.sol"

  • Smart contracts need to be written to implement the functionality of DApps
  • To test this functionality, Remix IDE can be used
    • Deploy the smart contract
    • Transact with the smart contract
    • Deposit the required amount
    • Check the withdrawn amount

Metamask Wallet

  • Metamask wallet can be used to integrate and deploy
  • Any test network on Metamask can be used
  • The Goerli Testnet (PoA consensus -> PoS with open validators) or Sepolia testnet (a Proof-of-Stake (PoS) testnet with permissioned validators)
  • Deploy on the Goerli Testnet using the Metamask account using the deployment tab.

Frontend Development

  • To develop the frontend contract address and the ABI are required for separate notepad.

Frontend Development of Smart Contracts

  • To load the index.html, a visual studio-like text editor is required.
  • Edit the contract address to match in step 4.
  • Edit the ABI file to the copied ABI from step 4.

Interacting with Smart contract using frontend

  • Go to xampp installation and move the updated index.html file to the htdocs folder.
  • Start the xampp web server.
  • Open the money smart contract using the Admin button and launch it in the web browser.
  • Interact with the smart contract front end with localhost/index.html.

IPFS Introduction

  • InterPlanetary File System (IPFS) is a peer-to-peer distributed file system.
  • IPFS stores files and tracks all the transactions on the distributed network.
  • It's a combinational technology of the version controlling system and P2P network spread over a global namespace.
  • IPFS is a single BitTorrent swarm, exchanging objects within one Git repository.
  • In contrast to a central storage based file system, IPFS works on a decentralized system.
  • Every user in the network holds a portion of the overall data, creating a resilient system for storage and sharing over the globe.
  • Any user in the network can share a file which is accessible to everyone by requesting from a node using DHT(Distributed Hash Table)

HTTP issues

  • HTTP is a request-response based protocol
  • When a web browser sends a request to an external server, the function of the server is to return the request with a response message.
  • HTTP faces problems when there is a disruption in the network or when the client can't connect with the server.
  • HTTP web is usually full of broken links in the network.
  • HTTP with its location-based addressing model encourages centralization.
  • The data is becoming siloed on the web.

IPFS Addressing

  • Content is addressed by using IPFS instead of HTTP
  • IPFS guarantees a permanent and distributed web by incorporating content-addressed system, instead of location-based (used by HTTP).
  • IPFS uses a form of representation by integrating a hash on a file, which is taken as the address.
  • The hash is a root object, and it provides its path to other objects as well.
  • As opposed to requesting a server for data access, you can gain access to this hash, which acts as a starting point of data.
  • We can reach the peer who has the content at the hash location, and download the content from the node which holds the data.
  • A DHT or Distributed Hash Table is used by IPFS for storing data.

IPFS Components

  • Distributed Hash Table
  • Merkle DAG
  • Version Control System
  • Self-certifying File System

Building the DHT

  • Discovery: Ask for CID 1
  • Peer B has CID 1
  • Request CID 1 from Peer B
  • Peer B sends Block CID 1

Summarizing IPFS

  • Content is accessible through peers, located anywhere, that relay information, store it, or do both.
  • IPFS finds what you ask for via its content address.
  • Three fundamental IPFS principles:
    • Unique identification via content addressing.
    • Content linking via directed acyclic graphs (DAGs).
    • Content discovery via distributed hash tables (DHTs).

Installing IPFS for Lab

DAOs Background

  • DAO (Decentralized Autonomous Organization) is an early example of tokenizing ether Purpose is a Venture Capital Fund for blockchain-based investments that would be directed by investors (owners of the DAO token).
  • It is a smart contract on Ethereum blockchain designed by Slock.it
  • Lacks a management structure, a Board of Directors, and employees
  • The code was open-source and stateless.

DAO Launch

  • Launched in April 2016 on Ethereum block 1428757 with a crowdsale to fund the organization.
  • Ether value was about $150 million by May 21 (about 14% of all ether at the time).

DAO Reentrancy Bug

  • June 9, 2016: Two developers reported most Ethereum-based contracts managing funds were vulnerable to a bug (Reentrancy Bug).
  • June 12, 2016: Stephan Tual (Slock.it founder) reported that The DAO code was not vulnerable to this exploit.
  • The code had two lines in the wrong order, allowing repeated ether withdrawals before checking entitlement.
  • June 17, 2016: The DAO was attacked, and a user gained access to ~$50 million of ETH (30% of ether in the contract). Another group, Robin Hood Group (RHG), simultaneously used a similar exploit, promising to return ether to owners (they got the remaining 70%).

Community Debate

  • The funds were put in a 28-day holding period before they could be withdrawn.
  • The community debated rewriting history by hard forking, with a July 20 deadline (end of 28-day period).

The Hard Fork

  • July 20, 2016: A hard fork at block 1,920,000 rewrote history, returning the DAO-directed ether to investors.
  • The old protocol, Ethereum Classic (ETC), preserved history (immutability property), mandating RHG to return 70% of the ETC to the original investors.

Hard Fork vs. Soft Fork

  • Soft Forks:
    • Relatively minor software changes.
    • Software upgrades backward-compatible with previous versions.
    • Nodes do not need upgrading to form consensus.
  • Hard forks:
    • Major software changes.
    • Not backward-compatible with previous versions.
    • New rules for node consensus.
    • It can be planned (Constantinople) or contentious (ETC).

Lessons from the DAO Incident

  • Smart Contracts:
    • Are not always smart and once deployed, cannot be "fixed."

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Use Quizgecko on...
Browser
Browser