­­FIN451 / MBA651 Blockchain Class Web Page, Fall ' 24

Instructor: Maggie Foley

Jacksonville University

 

The Syllabus           Risk Tolerance Assessment       Term Project: Just complete a smart contract and a DApp

 

Weekly SCHEDULE, LINKS, FILES and Questions

Chapter

Coverage, HW, Supplements

-       Required

References

 

Week 1

 

Week 1 - The basics of Bitcoins and Blockchains by Mr. Lewis

https://www.youtube.com/watch?v=-xEdF8utQNE&t=650s (audiobook)

Cryptography: from 2:38:27 to 3:10:08

Bitcoin:  from 3:10:08 to 5:41:05

Etherum  from 5:41:05 to 8:08:51

 

PPT  on Cryptography

 

Blockchain in general, Bitcoin, Bitcoin Mining, POW   PPT     Quiz1

·       Also watch Blockchain Full Course - 4 Hours |Simplilearn (from beginning to 1:20:10)

https://www.youtube.com/watch?v=SyVMma1IkXM&t=4849s

 

Blockchain in general, and Bitcoin

1. What is Bitcoin?

  • Definition: Bitcoin is a decentralized digital currency, created in 2009 by an unknown person or group of people using the pseudonym Satoshi Nakamoto. It operates without a central authority or banks.
  • How it works: Bitcoin transactions are recorded on a public ledger called the blockchain, which is maintained by a network of computers (nodes).

2. The Technology Behind Bitcoin

  • Blockchain: The concept of blockchain as a distributed ledger that records all transactions across a network of computers. Each block in the chain contains a list of transactions and is linked to the previous block, forming a chain.
  • Mining: The process of mining, where participants (miners) use computational power to solve complex mathematical problems that validate and secure transactions on the Bitcoin network. In return, miners are rewarded with newly created bitcoins.

3. Why Bitcoin?

  • Decentralization: Unlike traditional currencies, Bitcoin is not controlled by any central government or institution. This decentralization is a key feature that attracts many users.
  • Limited Supply: There will only ever be 21 million bitcoins, which creates scarcity and can drive demand.
  • Transparency and Security: Bitcoin transactions are transparent and secure, thanks to the blockchain. Transactions cannot be altered once they are recorded, which provides a high level of security.

4. How to Use Bitcoin

  • Transactions: Bitcoin can be used to buy goods and services, transferred between individuals, or held as an investment.
  • Wallets: The concept of Bitcoin wallets, which are digital tools that allow users to send, receive, and store their bitcoins. Wallets can be software-based (like apps) or hardware-based (physical devices).

5. The Impact of Bitcoin

  • Financial Innovation: Bitcoin is considered the first successful cryptocurrency and has paved the way for thousands of other digital currencies.
  • Global Economy: The potential impact of Bitcoin on the global financial system, including topics like financial inclusion, remittances, and challenges to traditional banking systems.
  • Challenges and Criticisms: Some challenges Bitcoin faces, such as regulatory issues, price volatility, and environmental concerns related to mining.

6. Future of Bitcoin

  • Adoption: Growing acceptance of Bitcoin by businesses, investors, and even some governments.
  • Technological Advancements: Mention ongoing developments, such as the Lightning Network, which aims to make Bitcoin transactions faster and cheaper.

 

Bitcoin Mining   Blockchain Full Course - 4 Hours by Simplilearn (2:16:48 – 2:34:44)   PPT       Quiz    Bitcoin_Mining_Simulator

1.    What is Bitcoin Mining?

  • Definition: Bitcoin mining is the process by which new bitcoins are created and transactions are added to the blockchain, the public ledger of all Bitcoin transactions.
  • Analogy: Think of Bitcoin mining as a competitive game. In this game, participants (called miners) are trying to solve a really difficult puzzle. The first one to solve the puzzle gets to add a new block of transactions to the blockchain and is rewarded with new bitcoins.

2. The Role of Hashing

  • What is Hashing? Hashing is like taking a piece of information (like a list of transactions) and running it through a special mathematical function that turns it into a unique string of numbers and letters. This string is called a "hash."
  • Analogy: Imagine hashing as a blender. You put in different ingredients (transactions), blend them, and what comes out is a smoothie (the hash). Even if you slightly change the ingredients (like changing a single transaction), youll get a completely different smoothie (hash).

3. Proof of Work (PoW)

  • Definition: Proof of Work is the mechanism that makes Bitcoin mining possible. It requires miners to solve a complex mathematical problem before they can add a new block to the blockchain. This problem is solved by finding a special kind of hash.
  • How it Works:
    • The puzzle miners are trying to solve involves finding a hash that starts with a certain number of zeros.
    • Miners do this by trying different inputs (numbers called "nonces") until they find one that, when hashed, produces the required hash with the zeros.
    • The process takes a lot of computational power because miners have to try many different nonces before they find the right one.
  • Analogy: Think of PoW as a guessing game. The game asks miners to guess a number, but the only way to know if the guess is correct is to try it and see if it works. This means miners have to make many, many guesses before they get it right.

4. Why is Mining Important?

  • Security: The difficulty of solving the PoW puzzle ensures that Bitcoin's blockchain is secure. Because it takes so much effort to solve, its practically impossible for someone to change or tamper with a block once its been added to the blockchain.
  • Decentralization: Mining is decentralized, meaning that anyone with the right equipment can participate, which helps keep the Bitcoin network fair and secure.

5. Mining Rewards

  • Block Reward: When a miner successfully solves the PoW puzzle and adds a new block to the blockchain, they are rewarded with a certain number of bitcoins. This is called the block reward.
  • Transaction Fees: In addition to the block reward, miners also earn transaction fees from the transactions included in the block they added to the blockchain.

6. Environmental Concerns

  • Energy Use: Mining requires a lot of computational power, which in turn requires a lot of electricity. This has raised concerns about the environmental impact of Bitcoin mining.
  • Efforts to Improve: The Bitcoin community is continually looking for ways to make mining more energy-efficient, including exploring alternative consensus mechanisms and renewable energy sources.

Summary

  • Bitcoin mining is the process of adding new transactions to the blockchain and earning new bitcoins as a reward.
  • Hashing is used to turn transaction data into a unique code, and miners must find a specific type of hash to solve the PoW puzzle.
  • PoW is a guessing game that ensures Bitcoins security by making it hard to alter the blockchain.

 

 

PPT on Bitcoin Wallet   ppt    Quiz

 Simplilearn 4 hour course (2:35:34 2:57:05)    Crypto Wallet Simulator

 

1. What is a Bitcoin Wallet?

  • Definition: A Bitcoin wallet is a digital tool that allows you to send, receive, and store your bitcoins. Its like a bank account for your bitcoins, but instead of holding physical money, it holds digital currency.
  • Analogy: Imagine a Bitcoin wallet as a real wallet you carry in your pocket. Just like you use your physical wallet to store cash, a Bitcoin wallet stores your digital money (bitcoins).

2. How Does a Bitcoin Wallet Work?

  • Private Key and Public Key:
    • Private Key: This is a secret code that allows you to access and control your bitcoins. Its like the password to your bank account. If someone has your private key, they can spend your bitcoins, so its essential to keep it safe.
    • Public Key: This is like your bank account number. Its a code that people use to send you bitcoins. You can share your public key with others, and they can use it to send bitcoins to your wallet.
  • Analogy: Think of your private key as the key to a safety deposit box. Only you should have access to this key because it gives you control over the money inside. The public key is like the address of the bank where your safety deposit box is located, which others can use to send money to your box.

3. Types of Bitcoin Wallets

  • Software Wallets:
    • These are apps or programs you can install on your computer or smartphone. They allow you to easily access and manage your bitcoins.
    • Example: Mobile wallets like Coinbase or desktop wallets like Electrum.
  • Hardware Wallets:
    • These are physical devices, like a USB stick, that store your private keys offline. They are more secure because they are not connected to the internet, making them less vulnerable to hacking.
    • Example: Ledger Nano S, Trezor.
  • Paper Wallets:
    • This is a piece of paper with your public and private keys printed on it. Its a very secure way to store bitcoins, as long as you keep the paper safe.
    • Example: You generate a paper wallet using a secure online service, then print it out and store it in a safe place.
  • Analogy: If a software wallet is like an app on your phone, a hardware wallet is like a safe that you keep at home, and a paper wallet is like writing down your bank details on a piece of paper and keeping it in a safe place.

4. Why Use a Bitcoin Wallet?

  • Security: A Bitcoin wallet helps keep your bitcoins safe. By securely storing your private key, you control who can access your funds.
  • Convenience: Bitcoin wallets make it easy to send and receive bitcoins. You can quickly make transactions by scanning a QR code or entering an address.
  • Ownership: When you have a Bitcoin wallet, you have full control over your bitcoins. No one else can access your funds unless they have your private key.

5. How to Use a Bitcoin Wallet

  • Receiving Bitcoins:
    • To receive bitcoins, you give someone your public key (or wallet address). They send the bitcoins to that address, and it shows up in your wallet.
    • Example: You can send your friend a QR code that represents your wallet address, and they can scan it to send you bitcoins.
  • Sending Bitcoins:
    • To send bitcoins, you enter the recipients wallet address and the amount you want to send. The wallet uses your private key to authorize the transaction.
    • Example: If you want to pay for something online with Bitcoin, you would enter the seller's wallet address and send the payment through your wallet.

6. Security Tips

  • Backup: Always back up your wallet. If you lose your private key, you lose your bitcoins forever.
  • Secure Storage: Keep your private key safe. Use hardware wallets or paper wallets for long-term storage, especially if you have a significant amount of bitcoins.
  • Beware of Scams: Never share your private key with anyone, and be cautious of phishing attempts that try to steal your private key.

Summary

  • A Bitcoin wallet is a digital tool that stores your private and public keys, allowing you to send, receive, and store bitcoins.
  • There are different types of wallets (software, hardware, paper), each offering varying levels of security and convenience.
  • Security is crucial; keep your private key safe and always back up your wallet.

 

(Disclaimer: Some of the slides posted on this website are screenshots from the Simplilearn 4 Hour Blockchain video at https://www.youtube.com/watch?v=SyVMma1IkXM&t=4849s)

 

 

Quiz to assess knowledge on the first day of class  

 

Bitaddress.org  

Bitaddress.org is an open-source, web-based tool for generating Bitcoin addresses and their corresponding private keys. It's a simple and secure way to create Bitcoin wallets offline, without needing to rely on a centralized service.

How to Use Bitaddress.org:

1.     Access the Site: Go to bitaddress.org. To enhance security, you can download the sites HTML file and run it offline.

2.     Generate a Bitcoin Address:

·       Move your mouse around or type random characters in the provided box to add randomness. This process helps in generating a unique Bitcoin address.

·       Once enough randomness is collected, a Bitcoin address and its corresponding private key will be displayed.

3.     Save Your Keys:

·       You can print the generated address and private key on paper (often called a paper wallet).

·       Store the printed document securely, as anyone with access to your private key can access your Bitcoin.

4.     Use the Address:

·       The Bitcoin address can be shared with others to receive Bitcoin.

·       The private key is used to send or transfer Bitcoin from that address.

Important: Always ensure you are using Bitaddress.org securely, preferably offline, and keep your private key safe to prevent unauthorized access to your funds.

 

https://etherscan.io/

Etherscan.com is a popular blockchain explorer specifically designed for the Ethereum network. It allows users to explore and search the Ethereum blockchain for transactions, addresses, tokens, prices, and other activities.

Key Features of Etherscan:

1.     Transaction Tracking:

·       You can search for any Ethereum transaction by entering its transaction hash (TXID) into the search bar. This will provide details such as the amount transferred, gas fees, block confirmation, and the status of the transaction (e.g., pending, successful, failed).

2.     Wallet and Address Lookup:

·       Etherscan allows you to view the balance and transaction history of any Ethereum address. Just enter the wallet address in the search bar to see the current Ether balance, list of ERC-20 tokens held, and transaction history.

3.     Smart Contract Interaction:

·       You can view, verify, and interact with smart contracts directly on Etherscan. It shows the contract's source code, ABI (Application Binary Interface), and allows you to execute functions if the contract is verified.

4.     Token Information:

·       Etherscan provides information on all ERC-20 tokens, including their contract address, holders, transactions, and price data.

5.     Gas Tracker:

·       The site features a gas tracker that shows real-time information on Ethereum gas prices, helping users choose optimal times for transactions to minimize fees.

How to Use Etherscan:

1.     Search Transactions or Addresses:

·       Enter a transaction hash, wallet address, or smart contract address into the search bar to retrieve detailed information.

2.     Explore Contracts:

·       If you're dealing with a smart contract, you can search for it on Etherscan to review its code, check its status, or interact with it directly.

3.     Check Gas Fees:

·       Use the gas tracker to monitor current gas prices and plan your transactions accordingly.

4.     Token Lookup:

·       Search for any ERC-20 token to view its distribution, market data, and associated transactions.

Etherscan is an essential tool for anyone working with Ethereum, offering transparency and a wealth of information about the blockchain.

 

 

 

 Useful Websites:

1.     Ethereum.org

    • Ethereum Official Site
    • Great resource for learning about Ethereum, the leading platform for decentralized applications (dApps) and smart contracts.

2.     Solidity Documentation // https://docs.soliditylang.org/en/v0.8.26/

    • Solidity Official Documentation
    • Comprehensive guide for learning Solidity, the programming language for writing smart contracts on Ethereum.

3.     Remix IDE https://remix.ethereum.org/#lang=en&optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.26+commit.8a97fa7a.js

    • Remix IDE
    • Online integrated development environment for Solidity development, providing tools for writing, testing, and debugging smart contracts.

4.     OpenZeppelin

    • OpenZeppelin
    • Framework for building secure smart contracts with libraries, tools, and educational resources.

5.     CryptoZombies

    • CryptoZombies
    • Interactive tutorial that teaches Solidity by guiding students through building their own blockchain-based game.

6.     Truffle Suite

    • Truffle Suite
    • Development environment, testing framework, and asset pipeline for Ethereum, aimed at making development easier.

7.     Hardhat

    • Hardhat
    • Ethereum development environment for professionals, with features for compiling, deploying, testing, and debugging Solidity code.

8.     Dapp University

    • Dapp University
    • Offers tutorials and courses on blockchain development, including Solidity and Ethereum.

9.     Solidity by Example

10.  EthHub  https://docs.ethhub.io/

    • EthHub
    • Comprehensive resources on Ethereum, including guides on smart contracts, Solidity, and blockchain development.

11.  Chainlink Documentation  https://docs.chain.link

    • Chainlink Documentation
    • Resources for integrating Chainlink decentralized oracles with smart contracts to enable off-chain data access.

12.  Ethers.js  https://docs.ethers.org/v6/

    • Ethers.js
    • JavaScript library for interacting with the Ethereum blockchain, useful for front-end developers integrating smart contracts.

13.  DeFi Pulse

    • DeFi Pulse
    • Track the latest stats and trends in decentralized finance (DeFi) projects.

14.  State of the DApps

    • State of the DApps
    • Directory and analytics for decentralized applications, showcasing the latest dApps and their usage statistics.

15.  Github

 

 

Websites for beginners learning about Ethereum and blockchain:

1.     Ethereum Foundation Blog https://blog.ethereum.org/

    • Ethereum Foundation Blog
    • Official blog with updates, news, and educational articles about Ethereum.

2.     Consensys Academy  https://consensys.io/academy

    • Consensys Academy
    • Offers courses and resources on Ethereum development, blockchain basics, and more.

3.     Blockgeeks

    • Blockgeeks
    • Provides educational articles, guides, and courses on blockchain technology and Ethereum.

4.     Coursera - Blockchain Specialization

5.     CryptoCompare

    • CryptoCompare
    • Provides data, news, and educational resources on cryptocurrencies and blockchain technology.

6.     CoinDesk

    • CoinDesk
    • Leading news website that covers blockchain, Ethereum, and cryptocurrency trends and developments.

7.     DappRadar

    • DappRadar
    • A platform for exploring and tracking decentralized applications (dApps) across multiple blockchains.

8.     The Ethereum Reddit Community

    • Ethereum Subreddit
    • A community forum where beginners can ask questions, share information, and learn more about Ethereum.

9.     Binance Academy  https://academy.binance.com/\

    • Binance Academy
    • Provides educational resources on blockchain, cryptocurrency, and decentralized finance (DeFi).

 

 

Week 2

Week 2 – Ethereum

 

Part I – What is Ethereum? A Comparison between Ethereum and Bitcoin    Quiz2

What is Ethereum?    PPT  Simplilearn 4 hour Blockchain Video (from  1:26:00 – 2:19:34 )

1. Introduction to Ethereum

  • Definition: Ethereum is a decentralized, open-source blockchain platform that enables developers to build and deploy decentralized applications (dApps) and smart contracts. It was proposed by Vitalik Buterin in 2013 and launched in 2015.
  • Purpose: While Bitcoin was created as a digital currency, Ethereum was designed to be a more versatile platform, allowing for the creation of decentralized applications beyond just currency.

2. Key Features of Ethereum

  • Smart Contracts:
    • Definition: Smart contracts are self-executing contracts with the terms of the agreement directly written into code. They automatically enforce and execute the contract when certain conditions are met, without the need for intermediaries.
    • Example: Imagine a vending machine as a smart contract. You insert money, select a product, and the machine automatically delivers it to you. There's no need for a cashier because the contract (machine) handles everything.
  • Ethereum Virtual Machine (EVM):
    • Definition: The EVM is a global decentralized computer that runs the smart contracts on the Ethereum network. It allows anyone to execute code in a decentralized manner, ensuring that the same result is achieved everywhere.
  • Decentralized Applications (dApps):
    • Definition: dApps are applications that run on a blockchain network rather than a central server. They leverage Ethereums smart contracts to function without a central authority.
    • Example: A decentralized social media platform where users control their data, and no single entity can censor or remove content.

 

3.     A Comparison between Bitcoin and Ethereum  PPT   Simplilearn 4 hour video (2:57:06 – 3:03:00)

Feature

Bitcoin

Ethereum

Primary Purpose

Digital currency (peer-to-peer transactions)

Platform for decentralized applications and smart contracts

Launch Year

2009

2015

Founder

Satoshi Nakamoto (pseudonymous)

Vitalik Buterin

Native Cryptocurrency

Bitcoin (BTC)

Ether (ETH)

Supply

Maximum supply of 21 million BTC

No fixed supply; continuous issuance of ETH

Blockchain Structure

Simple, secure, focused on transactions

Complex, programmable, supports smart contracts and dApps

Consensus Mechanism

Proof of Work (PoW)

Transitioning from PoW to Proof of Stake (PoS) with Ethereum 2.0

Transaction Speed

~10 minutes per block

~15 seconds per block

Scalability

Handles ~7 transactions per second (TPS)

More scalable; ongoing upgrades like Ethereum 2.0 aim to further improve scalability

Smart Contracts

Not supported

Fully supported; core feature of the platform

Decentralized Applications (dApps)

Not supported

Fully supported; numerous dApps are built on Ethereum

Use Case

Digital money, store of value

Platform for building decentralized applications and smart contracts

Energy Efficiency

Energy-intensive due to PoW mining

Moving towards energy efficiency with PoS in Ethereum 2.0

Nickname

Often referred to as "Digital Gold"

Sometimes called "Programmable Blockchain"

 

Part II – Ethereum Mining  ppt   

 

1. What is Ether Mining?

  • Definition: Ether mining is the process of validating transactions on the Ethereum blockchain and adding them to the public ledger. Miners use computational power to solve complex mathematical puzzles, and in return, they are rewarded with newly created Ether.

2. How Ether Mining Works

  • Proof of Work (PoW): Ethereum currently uses the Proof of Work (PoW) consensus mechanism, similar to Bitcoin. Miners compete to solve cryptographic puzzles, and the first one to solve it gets to add a block of transactions to the blockchain and earns Ether as a reward.
  • Hashing: To solve the puzzle, miners use a hashing function (specifically, Ethash for Ethereum). They repeatedly process the block data through the hashing function with different "nonces" (random numbers) until they find a hash that meets the networks difficulty target.

3. Equipment Needed

  • Mining Hardware: To mine Ether, you need a powerful computer with a high-performance GPU (Graphics Processing Unit). GPUs are preferred for mining because they are more efficient than CPUs for the type of calculations involved in mining.
  • Mining Software: Youll need mining software that connects your hardware to the Ethereum network. Popular mining software includes Ethminer, PhoenixMiner, and Claymore.
  • Ethereum Wallet: Youll need an Ethereum wallet to store the Ether you mine. This can be a software wallet (like MetaMask) or a hardware wallet (like Ledger or Trezor) for added security.

4. Mining Solo vs. Joining a Pool

  • Solo Mining: In solo mining, you mine independently. While the rewards can be significant if you solve a block, its highly competitive and may take a long time before you find a block.
  • Mining Pool: Most miners join a mining pool, where multiple miners work together to solve blocks. The rewards are shared among all participants based on the amount of computational power they contribute. This provides more consistent, though smaller, earnings.

5. Steps to Start Mining Ether

  1. Set Up Hardware: Install and configure your mining hardware, ensuring you have a powerful GPU.
  2. Install Mining Software: Download and install your chosen mining software.
  3. Join a Mining Pool: If you prefer, join a mining pool to increase your chances of earning rewards regularly.
  4. Start Mining: Begin mining by running the mining software, which will connect your hardware to the Ethereum network and start solving cryptographic puzzles.
  5. Monitor and Optimize: Regularly monitor your mining performance and optimize your setup to ensure efficient mining.

6. Transition to Proof of Stake (PoS)

  • Ethereum 2.0: Ethereum is transitioning from Proof of Work (PoW) to Proof of Stake (PoS) with Ethereum 2.0. In PoS, validators are chosen to create new blocks based on the amount of Ether they hold and "stake." This transition will eventually make mining obsolete as the network moves towards staking.

 

 

 

Part III – Smart Contract   PPT   Simplilearn 4 hour video (from 1:27:14  to 2:13:44  )   Quiz

1. Definition

  • Smart Contract: A smart contract is a self-executing contract with the terms of the agreement directly written into lines of code. It automatically enforces and executes the contract when certain conditions are met, without the need for intermediaries like lawyers or banks.

2. How Smart Contracts Work

  • Code and Conditions: The smart contract is programmed to perform specific actions when certain predefined conditions are met. For example, a smart contract could be set up to transfer ownership of a digital asset automatically when payment is received.
  • Decentralization: Smart contracts run on a decentralized blockchain network like Ethereum, meaning no single entity controls them. Once deployed, they are immutable (cannot be changed) and transparent, with the code visible to all participants.

3. Example of a Smart Contract

  • Real Estate Transaction: Imagine buying a house through a smart contract. The contract could be programmed to automatically transfer ownership of the property to the buyer when the agreed payment is received. This eliminates the need for a middleman, like a lawyer, to verify and process the transaction.

Software Needed for Smart Contracts

1. Development Environment

  • Solidity: Solidity is the most commonly used programming language for writing smart contracts on the Ethereum blockchain. Its similar to JavaScript in syntax and is specifically designed for developing smart contracts.
  • Remix IDE: Remix is an online Integrated Development Environment (IDE) that allows developers to write, compile, and deploy smart contracts in Solidity. Its beginner-friendly and widely used for Ethereum smart contract development.

2. Blockchain Network

  • Ethereum: Ethereum is the most popular blockchain platform for deploying smart contracts. It provides a decentralized environment where smart contracts can be executed securely and transparently.
  • Testnets: Before deploying a smart contract on the Ethereum mainnet (the live blockchain), developers typically use testnets like Ropsten or Rinkeby to test their contracts. This allows them to identify and fix any issues without risking real Ether.

3. Wallet and Blockchain Interface

  • MetaMask: MetaMask is a browser extension wallet that allows users to interact with Ethereum dApps and smart contracts. It also provides a way to manage your Ether and deploy smart contracts.
  • Truffle Suite: Truffle is a development framework for Ethereum that provides tools for compiling, deploying, and managing smart contracts. Its often used in larger, more complex smart contract projects.

Why Do We Need Smart Contracts?

1. Automation

  • Self-Executing: Smart contracts automate processes that would normally require manual intervention. For example, a smart contract can automatically release funds when a task is completed or a condition is met, reducing the need for middlemen.

2. Trust and Transparency

  • Immutable and Transparent: Once deployed, smart contracts cannot be altered, ensuring that the terms of the agreement are always enforced as written. The contracts code is also visible to everyone on the blockchain, which increases transparency and trust among participants.

3. Cost Efficiency

  • Reduced Costs: By eliminating intermediaries (like lawyers, notaries, or escrow services), smart contracts reduce transaction costs. This is especially beneficial in industries like finance, real estate, and supply chain management, where traditional processes can be slow and expensive.

4. Security

  • Blockchain Security: Smart contracts benefit from the security of the underlying blockchain. Since they are decentralized and cryptographically secure, they are highly resistant to fraud, tampering, and censorship.

5. Global Reach

  • Borderless: Smart contracts can be used globally without the need for intermediaries or cross-border legal considerations, making them ideal for international transactions and agreements.

Summary

  • Smart contracts are self-executing contracts written in code that automatically enforce and execute agreements without intermediaries.
  • They require specific software tools, including Solidity for programming, Remix for development, and Ethereum as the blockchain platform.
  • Smart contracts offer automation, transparency, cost efficiency, security, and global reach, making them valuable in many industries.

 

Part IV – Solidity Coding    PPT   Simplilearn 6 hour video (from 1:26:00 – 2:41:55  )

1. Introduction to Solidity

  • Definition: Solidity is a high-level programming language designed specifically for writing smart contracts on the Ethereum blockchain. Its statically typed and contract-oriented, meaning it allows developers to define the data structure and functions that will govern the behavior of the smart contract.
  • Similarities to JavaScript: Solidity syntax is similar to JavaScript, making it easier to learn for those who are already familiar with web development.

2. Purpose of Solidity

  • Smart Contract Development: Solidity is used to create smart contracts that can handle various functions, such as transferring tokens, enforcing agreements, creating decentralized applications (dApps), and more.
  • Blockchain Interaction: Contracts written in Solidity can interact with the Ethereum blockchain, allowing developers to create decentralized and secure applications.

How to Compile and Deploy a Solidity Contract

1. Writing a Smart Contract

  • Using Solidity: Start by writing the smart contract in Solidity. You can use a basic text editor, but its better to use a specialized Integrated Development Environment (IDE) like Remix.
  • Example Contract:
pragma solidity ^0.8.0;
 
contract SimpleStorage {
    uint256 storedData;
 
    function set(uint256 x) public {
        storedData = x;
    }
 
    function get() public view returns (uint256) {
        return storedData;
    }
}
  • Explanation: In this simple contract, there is a variable storedData that can be set and retrieved through the set and get functions.

2. Compiling the Smart Contract

  • Using Remix IDE:
    • Open Remix at remix.ethereum.org.
    • Create a new file and paste your Solidity code into the editor.
    • Select the compiler version (e.g., 0.8.0) that matches the pragma statement in your code.
    • Click on the "Compile" button. If there are no errors, your contract will be compiled into bytecode, which is what the Ethereum Virtual Machine (EVM) can execute.
  • Output: The compiler will generate ABI (Application Binary Interface) and bytecode, which are essential for deploying and interacting with the contract.

3. Deploying the Smart Contract

  • Using Remix with MetaMask:
    • Set Up MetaMask: Install the MetaMask browser extension and set up a wallet. Make sure you have some Ether in your wallet for gas fees (you can use test Ether on a test network like Ropsten).
    • Deploy: In Remix, switch to the "Deploy & Run Transactions" tab. Select "Injected Web3" as the environment to connect Remix with MetaMask.
    • Deploy the Contract: Select your contract from the dropdown and click "Deploy." MetaMask will prompt you to confirm the transaction, which includes paying a gas fee.
    • Confirm Deployment: Once confirmed, the contract will be deployed to the Ethereum network (or testnet), and youll receive a contract address where it resides on the blockchain.

Procedure Summary

  1. Write your smart contract in Solidity using an IDE like Remix.
  2. Compile the contract using the built-in compiler in Remix, generating ABI and bytecode.
  3. Deploy the contract to the Ethereum network via Remix and MetaMask.
  4. Interact with the deployed contract using the contracts functions through Remix or any other Ethereum interface.

Main Troubleshooting Issues

1. Compilation Errors

  • Syntax Errors: Most compilation errors come from incorrect syntax. Always ensure that your Solidity code adheres to proper syntax rules. Common issues include missing semicolons, mismatched brackets, or incorrect function declarations.
  • Version Mismatch: Ensure that the Solidity version in your pragma statement (e.g., pragma solidity ^0.8.0;) matches the version selected in the Remix compiler. If theres a mismatch, the contract might not compile or behave as expected.

2. Deployment Issues

  • Gas Limit Errors: Deployment can fail if the gas limit is too low. The gas limit is the maximum amount of gas youre willing to spend on the transaction. If its set too low, the contract wont deploy. Adjust the gas limit in MetaMask or the deployment settings in Remix.
  • Network Issues: Make sure you are connected to the correct Ethereum network (mainnet, Ropsten, etc.) via MetaMask. Deployment can fail if youre on the wrong network or if theres a network outage.

3. Interaction Issues

  • Contract Not Found: If you try to interact with a contract and get an error saying its not found, double-check the contract address. Ensure youre using the correct address on the correct network.
  • Incorrect Data Types: When interacting with the contracts functions, ensure youre passing the correct data types. For example, if a function expects a uint256, sending a string will cause an error.

4. Gas Estimation Errors

  • Incorrect Gas Estimation: Sometimes, the gas estimation might be too low for certain complex operations. In such cases, manually increase the gas limit in MetaMask or your Ethereum client.
  • High Gas Fees: Gas fees can fluctuate based on network congestion. If gas fees are too high, consider waiting for a less congested time or deploying to a test network.

Conclusion

  • Solidity coding allows developers to create and deploy smart contracts on the Ethereum blockchain.
  • Compiling and deploying a contract involves writing the code, compiling it to generate bytecode, and deploying it to the Ethereum network using tools like Remix and MetaMask.
  • Troubleshooting involves addressing common issues like syntax errors, gas limits, and network connectivity problems. Regular practice and careful attention to detail can help avoid many of these issues.

 

 

 

Part V – DApp (Decentralized Application) and DAO     PPT   Quiz

Simplilearn 4 hour video (from  3:02:31  to 3:09:15  )

1. Definition

  • DApp: A decentralized application (DApp) is an application that runs on a decentralized network, typically a blockchain like Ethereum, rather than on a centralized server. Unlike traditional apps, DApps are not controlled by a single entity and operate on a peer-to-peer network.

2. Key Characteristics of DApps

  • Decentralization: DApps are built on a blockchain, which is maintained by a distributed network of computers (nodes) rather than a single central authority. This ensures that no single entity has control over the application.
  • Open Source: Most DApps are open source, meaning their code is available for anyone to inspect, use, and modify. This transparency helps build trust among users.
  • Smart Contracts: DApps use smart contracts, which are self-executing contracts with the terms of the agreement directly written into code. These contracts automate various functions of the DApp without needing intermediaries.
  • Tokenization: Many DApps have their own tokens, which can be used within the application for various purposes, such as payments, voting, or rewarding users. These tokens are often created using Ethereums ERC-20 or ERC-721 standards.

3. How DApps Work

  • Frontend: Like traditional apps, DApps have a user interface (frontend) that users interact with. This can be a website, mobile app, or any other user interface.
  • Backend: Unlike traditional apps, the backend of a DApp consists of smart contracts deployed on a blockchain. The logic and data of the DApp are stored on the blockchain, making it immutable and transparent.
  • Interacting with the Blockchain: Users interact with the DApp through a web browser that connects to the blockchain. For example, MetaMask is a popular browser extension that allows users to interact with Ethereum-based DApps.

4. Examples of DApps

  • Decentralized Finance (DeFi): Platforms like Uniswap (a decentralized exchange) and Aave (a lending platform) allow users to trade and lend cryptocurrencies without relying on traditional financial institutions.
  • Gaming: Games like CryptoKitties allow users to buy, breed, and trade virtual cats as non-fungible tokens (NFTs). These assets are owned by the users and exist on the blockchain.
  • Social Media: Platforms like Steemit offer decentralized social networks where users can earn tokens for creating and curating content, with no central authority controlling the platform.

Why Do We Need DApps?

1. Trust and Security

  • Transparency: Because DApps run on a blockchain, all transactions and actions are transparent and verifiable by anyone. This reduces the need to trust a central authority.
  • Security: DApps are more resistant to hacking and censorship because they are decentralized. Even if one part of the network goes down or is compromised, the rest of the network continues to function.

2. User Control and Ownership

  • Data Ownership: In traditional apps, user data is often controlled and monetized by the company that owns the app. In DApps, users have greater control over their data, which is stored on the blockchain and cannot be easily tampered with.
  • Asset Ownership: In DApps that involve digital assets (like tokens or NFTs), users truly own their assets. For example, if you own an NFT in a DApp, it is stored on the blockchain and cannot be taken away by anyone.

3. Innovation and Accessibility

  • Global Access: DApps are accessible to anyone with an internet connection, making them available globally without the restrictions of traditional apps (like geographical restrictions or the need for a bank account).
  • Innovation: DApps enable new types of applications that werent possible before, such as decentralized finance (DeFi) platforms, decentralized exchanges, and blockchain-based games.

Challenges and Considerations

1. Scalability

  • Performance Issues: Since DApps run on a decentralized network, they can face scalability issues, such as slower transaction times and higher fees, especially during periods of high network congestion.
  • Ongoing Development: Developers are continuously working on solutions to improve the scalability and performance of DApps, such as layer 2 scaling solutions and more efficient consensus mechanisms.

2. User Experience

  • Complexity: Using DApps can be more complex than traditional apps, especially for users who are not familiar with blockchain technology. For example, users need to manage private keys and interact with smart contracts, which can be confusing for beginners.
  • Improving Accessibility: Efforts are being made to improve the user experience of DApps, making them more accessible to mainstream users without compromising their decentralized nature.

Conclusion

  • DApps are decentralized applications that run on blockchain networks, offering transparency, security, and user control.
  • They leverage smart contracts to automate processes and often use tokens for various functions within the app.
  • DApps are increasingly popular in fields like decentralized finance (DeFi), gaming, and social media, although they face challenges like scalability and user experience.

 

(Disclaimer: Some of the slides posted on this website are screenshots from the Simplilearn 4 Hour Blockchain video at https://www.youtube.com/watch?v=SyVMma1IkXM&t=4849s and Simplilearn 6 HourBlockchain Video at https://www.youtube.com/watch?v=9aXHQ98TMRY&t=6626s)

 

 

 

Part VI – Real World Examples     Quiz

 

1. Walmart Supply Chain Management

·        Overview: Walmart uses blockchain technology to improve the traceability and transparency of its food supply chain. This implementation helps Walmart quickly identify and address issues such as contamination or recalls, ensuring food safety and reducing waste.

·        Blockchain Platform: IBM Food Trust (built on Hyperledger Fabric)  https://www.ibm.com/products/supply-chain-intelligence-suite/food-trust

·        Website:

    • Walmart's Blockchain Initiative: IBM Food Trust for Walmart
    • IBM Food Trust: IBM Food Trust

·        Additional Information: Walmart was one of the first major retailers to adopt blockchain for supply chain management, initially focusing on tracing pork and leafy greens to enhance food safety.

2. Maersk Shipping and Logistics with TradeLens

·        Overview: Maersk, in collaboration with IBM, developed TradeLens, a blockchain-based platform designed to streamline global shipping processes. TradeLens enhances transparency, reduces paperwork, and increases efficiency by providing real-time access to shipping data and documents.

·        Blockchain Platform: TradeLens (built on Hyperledger Fabric)

·        Website: TradeLens   https://www.tradelens.com/

·        Additional Information: TradeLens has partnered with numerous shipping companies, ports, and customs authorities worldwide to create a more connected and efficient global trade ecosystem.

3. De Beers Diamond Provenance Tracking with Tracr

·        Overview: De Beers uses the Tracr platform to track diamonds from the mine to the retail point. This ensures that each diamond is ethically sourced and conflict-free, enhancing consumer trust and maintaining the integrity of their supply chain.

·        Blockchain Platform: Tracr (developed by De Beers)

·        Website: De Beers Tracr   https://www.tracr.com/

·        Additional Information: Tracr allows consumers to verify the origin and journey of their diamonds, promoting transparency and ethical sourcing in the diamond industry.

 

4. Nestlé – Food Supply Chain Transparency

·        Overview: Nestlé leverages blockchain technology to enhance the transparency and traceability of its food products. By tracking ingredients through the supply chain, Nestlé ensures quality, safety, and ethical sourcing.

·        Blockchain Platform: IBM Food Trust (built on Hyperledger Fabric)

·        Website: Nestlé and IBM Food Trust  https://www.ibm.com/blogs/think/2019/04/tracing-your-mashed-potatoes-on-ibm-blockchain/

·        Additional Information: Nestlé's participation in IBM Food Trust helps the company monitor the supply chain in real-time, ensuring that products meet safety standards and are sourced responsibly.

 

5. FedEx Package Tracking and Logistics

·        Overview: FedEx explores blockchain technology to improve its package tracking system, aiming for more secure and transparent tracking information for shipments. Blockchain enhances the reliability and efficiency of tracking packages through the supply chain.

·        Blockchain Platform: Potential Platforms: Hyperledger Fabric, Ethereum, or proprietary solutions

·        Website: FedEx Blockchain Initiatives   https://www.fedex.com/en-us/about/policy/technology-innovation/blockchain.html

·        Additional Information: FedEx has been involved in blockchain pilot projects to explore how distributed ledger technology can optimize logistics and reduce fraud.

 

6. Provenance Supply Chain Transparency for Various Industries

·        Overview: Provenance is a platform that helps businesses track the origins and journey of their products using blockchain. This ensures transparency, ethical sourcing, and allows consumers to verify product claims.

·        Blockchain Platform: Ethereum and other blockchain technologies

·        Website: Provenance  https://www.provenance.org/

·        Additional Information: Provenance works with various industries, including fashion, food, and consumer goods, to provide detailed product histories and build consumer trust through transparency.

 

7. Microsoft Azure Blockchain Services

·        Overview: Microsoft offers Azure Blockchain Services, enabling businesses to build, deploy, and manage blockchain applications easily. Numerous companies use Azure Blockchain to develop solutions across different industries such as finance, supply chain, and healthcare.

·        Blockchain Platform: Azure Blockchain (supports multiple blockchain frameworks including Ethereum, Hyperledger Fabric)

·        Website: Microsoft Azure Blockchain https://azure.microsoft.com/en-us/blog/digitizing-trust-azure-blockchain-service-simplifies-blockchain-development/

·        Additional Information: Azure Blockchain provides tools and templates to help enterprises integrate blockchain into their existing systems, facilitating faster and more secure transactions.

 

8. JPMorgan Chase Financial Services with Quorum

·        Overview: JPMorgan Chase developed Quorum, an enterprise-focused version of Ethereum, to facilitate secure and efficient financial transactions. Quorum is used for various applications, including payment processing, interbank transfers, and blockchain-based financial instruments.

·        Blockchain Platform: Quorum (a fork of Ethereum developed by JPMorgan Chase) https://phemex.com/academy/what-is-quorum-jp-morgan

·        Website: Quorum by ConsenSys  https://consensys.io/blog/what-is-consensys-quorum

·        Additional Information: Quorum enhances Ethereum's capabilities by adding privacy features and improving performance, making it suitable for enterprise use cases in the financial sector.

 

9. IBM Various Enterprise Blockchain Solutions

·        Overview: IBM offers a range of blockchain solutions tailored for different industries, including supply chain, finance, healthcare, and more. IBM Blockchain, built on Hyperledger Fabric, provides the infrastructure for businesses to create secure and scalable blockchain applications.

·        Blockchain Platform: IBM Blockchain (built on Hyperledger Fabric) 

·        Website: IBM Blockchain  https://www.ibm.com/blockchain

·        Additional Information: IBM collaborates with numerous enterprises to implement blockchain solutions that enhance transparency, security, and efficiency in their operations.

 

10. Amazon Web Services (AWS) Managed Blockchain Services

·        Overview: Amazon Web Services offers Amazon Managed Blockchain, a fully managed service that makes it easy to create and manage scalable blockchain networks using popular frameworks like Hyperledger Fabric and Ethereum.

·        Blockchain Platform: Amazon Managed Blockchain (supports Hyperledger Fabric and Ethereum)

·        Website: Amazon Managed Blockchain  Distributed Ledger Software & Technology - Amazon Managed Blockchain - AWS

·        Additional Information: AWS Managed Blockchain allows businesses to quickly set up and manage blockchain networks without the overhead of maintaining the underlying infrastructure, supporting various use cases from supply chain to digital identity.

 

11. Coca-Cola Supply Chain and Product Authentication

·        Overview: Coca-Cola utilizes blockchain technology to enhance its supply chain management and product authentication processes. Blockchain helps Coca-Cola track ingredients, ensure quality, and authenticate products to prevent counterfeiting.

·        Blockchain Platform: IBM Food Trust (built on Hyperledger Fabric)

·        Website: Coca-Cola and IBM Food Trust https://shping.com/shping-and-ibm-food-trust-pioneering-a-new-era-of-product-transparency-for-consumers/

·        Additional Information: By integrating blockchain into its supply chain, Coca-Cola ensures better transparency and efficiency, from sourcing raw materials to delivering finished products.

 

12. Pfizer Pharmaceutical Supply Chain Management

·        Overview: Pfizer uses blockchain to improve the traceability and security of its pharmaceutical supply chain. Blockchain helps Pfizer ensure the authenticity of medicines, prevent counterfeiting, and comply with regulatory requirements.

·        Blockchain Platform: Provenance, IBM Blockchain, or other enterprise blockchains

·        Website: Pfizer and Blockchain Initiatives   https://news.crunchbase.com/health-wellness-biotech/pharmaceuticals-blockchain-crypto-web3-pfizer-pfe/

·        Additional Information: Blockchain technology enables Pfizer to maintain a secure and transparent record of its supply chain, enhancing trust and safety in its pharmaceutical products.

 

13. Starbucks Coffee Supply Chain Tracking

·        Overview: Starbucks has explored using blockchain to track the provenance of its coffee beans, ensuring quality and ethical sourcing. Blockchain helps verify the journey of the coffee from farm to cup, enhancing transparency and consumer trust.

·        Blockchain Platform: IBM Food Trust (similar to Walmart and Nestlé)

·        Website: Starbucks and Blockchain  https://stories.starbucks.com/press/2022/starbucks-brewing-revolutionary-web3-experience-for-its-starbucks-rewards-members/

·        Additional Information: By leveraging blockchain, Starbucks can provide customers with detailed information about the origin and quality of their coffee, supporting sustainable and ethical sourcing practices.

 

14. BP Energy Supply Chain Management

·        Overview: BP utilizes blockchain technology to manage and optimize its energy supply chain. Blockchain helps BP track the movement of energy resources, ensure compliance with regulations, and improve the efficiency of transactions.

·        Blockchain Platform: IBM Blockchain or other enterprise solutions

·        Website: BP and Blockchain  https://www.hartenergy.com/exclusives/bp-tries-out-blockchain-energy-trading-30388

·        Additional Information: BP's adoption of blockchain in the energy sector demonstrates how blockchain can enhance transparency, reduce costs, and improve operational efficiency in complex supply chains.

 

15. Anheuser-Busch InBev Beverage Supply Chain Transparency

·        Overview: Anheuser-Busch InBev uses blockchain to enhance the transparency and efficiency of its beverage supply chain. Blockchain enables the company to track ingredients, monitor production processes, and ensure the authenticity of its products.

·        Blockchain Platform: IBM Food Trust (built on Hyperledger Fabric)

·        Website: AB InBev and IBM Food Trust   https://www.foodnavigator.com/Article/2019/08/06/Anheuser-Busch-InBev-joins-new-IBM-blockchain

·        Additional Information: By integrating blockchain into its supply chain, Anheuser-Busch InBev ensures better quality control, traceability, and consumer trust in its beverage products.

 

Company

Application

Token Use

Walmart, Nestlé, Coca-Cola, BP

Supply Chain Management (IBM Food Trust)

No use of Ether or specific tokens; focus on transparency and traceability.

Maersk

TradeLens (Shipping and Logistics)

No use of Ether or specific tokens; focus on logistics transparency.

De Beers

Tracr (Diamond Provenance Tracking)

No use of Ether or specific tokens; ensures ethical sourcing.

FedEx

Package Tracking and Logistics

No use of Ether or specific tokens; focuses on tracking and logistics.

Provenance

Supply Chain Transparency

May use tokens depending on implementation, not necessarily Ether.

Microsoft Azure Blockchain

Blockchain Services

Token use depends on the specific application; Ether or custom tokens can be used.

JPMorgan Chase

Quorum (Enterprise Blockchain)

Can use Ether or custom tokens depending on the application; often no tokens.

Uniswap

Decentralized Finance (DeFi)

Uses Ether (ETH) for transactions and its own token (UNI) for governance.

Amazon Managed Blockchain

Managed Blockchain Services

Token use depends on the specific application; not inherently tied to Ether.

Pfizer

Pharmaceutical Supply Chain Management

No use of Ether or specific tokens; focuses on supply chain security.

Starbucks

Coffee Supply Chain Tracking

No use of Ether or specific tokens; focuses on transparency.

 

 

Part VII  Understanding Web3                    Quiz

Refer to Chapter 8 of Hands-On Smart Contract Development with Solidity & Ethereum by Solorio, Kanna, and Hoover

              

1.     What is Web3?

Web3 refers to a collection of JavaScript libraries that allow developers to interact with the Ethereum blockchain, either remotely or locally. Think of it as the connection point between the blockchain and your smart contract or decentralized app (DApp). Web3 uses JSON RPC (Remote Procedure Call) to communicate with Ethereum nodes and helps you perform transactions, call smart contract methods, and read/write data from the blockchain.

2.     How Web3 Differs from Web 2.0

In traditional web applications (Web 2.0), a frontend (like React) interacts with a backend (a server and database) to process and store data. In contrast, Web3 allows your frontend to interact directly with the blockchain as if it were the backend. This eliminates the need for centralized databases and servers.

Web3 Application Flow

  • Frontend: Users interact with a frontend (such as a website built with React).
  • Web3: The frontend uses Web3 to make requests to the blockchain instead of a traditional backend.
  • Blockchain: Web3 communicates with Ethereum nodes via RPC to read and write data.

image_1.jpgThis is Web 2.0

image_2.jpgThis is Web 3.0

1.     Why Web3 is Important

Web3 is at the core of decentralized applications (DApps). Instead of relying on centralized servers and databases, Web3 allows applications to interact directly with the decentralized blockchain, enhancing security, transparency, and trust.

2.     Setting Up Web3

To use Web3 in your project, you first need to set up a provider that tells Web3 which Ethereum node to connect to. For example, if you are working with Ganache (a local Ethereum blockchain), you would connect as follows:

const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));

The provider is like the URL you use in a traditional web app to communicate with an API. It directs RPC calls from Web3 to the correct Ethereum node.

Providers

  • Local (e.g., Ganache): Connect to a local Ethereum node (e.g., Ganache for development).
  • Remote: Connect to public Ethereum nodes (like Infura or Alchemy).

3.     MetaMask for Web3 Injection

MetaMask is a browser extension that makes interacting with Web3 much easier. It:

  • Stores and manages your Ethereum accounts and private keys.
  • Allows you to sign transactions.
  • Pays gas fees for blockchain transactions.

Web3 detects MetaMask as a Web3 provider, enabling you to interact with the blockchain seamlessly.

4.     Application of Web3 in the Blockchain Space

Benefits of Web3:

  • Decentralization: No centralized control, making systems more secure and transparent.
  • Trust: Eliminates the need to trust intermediaries as the blockchain enforces rules.
  • Security: DApps built with Web3 are resistant to attacks and data breaches because of the decentralized nature of the blockchain.
  • Ownership: Users have full control of their assets, unlike traditional apps where data is controlled by centralized entities.

Applications of Web3:

·   Decentralized Finance (DeFi): Web3 is the backbone of DeFi applications, enabling peer-to-peer financial transactions.

·   Voting Systems: As demonstrated by the Voting DApp you built, Web3 allows decentralized and tamper-proof voting mechanisms.

·   Supply Chain: Companies use Web3 to track goods in a transparent and immutable way.

·   Gaming: Web3 powers blockchain-based games that allow players to earn and trade assets.

Platform

Type

Website

Description

How It Uses Web3

OpenSea

NFT Marketplace

OpenSea

A large decentralized marketplace for buying, selling, and discovering NFTs.

Uses Ethereum and Web3 to enable users to trade digital assets like NFTs directly from their Ethereum wallets.

Rarible

NFT Marketplace

Rarible

A community-driven NFT marketplace where users can mint, sell, and trade digital assets.

Connects to Ethereum via Web3 to facilitate transactions and allow users to mint and trade NFTs.

Decentraland

Virtual World (Metaverse)

Decentraland

A decentralized virtual world where users buy and trade virtual real estate and in-game assets.

Uses Web3 to allow players to purchase, sell, and trade virtual LAND and in-game items as NFTs on the Ethereum blockchain.

Foundation

NFT Marketplace for Artists

Foundation

A marketplace focused on empowering artists to create, sell, and auction digital art as NFTs.

Interacts with Ethereum through Web3 to allow artists and collectors to trade artwork in a decentralized manner.

Axie Infinity

Blockchain-Based Game

Axie Infinity

A play-to-earn blockchain-based game where users can battle, breed, and collect NFT-based pets.

Uses Web3 for managing in-game assets (NFTs) and allows players to earn cryptocurrency through in-game activities.

Zora

NFT Marketplace and Protocol

Zora

An open-source protocol for creators to tokenize and sell creative works such as art and media.

Utilizes Ethereum and Web3 to let users mint and trade NFTs in a decentralized fashion.

Uniswap

Decentralized Exchange (DeFi)

Uniswap

A decentralized exchange for trading Ethereum-based tokens, with no central authority or intermediaries.

Uses Web3 to allow users to swap tokens directly from their wallets, using smart contracts to facilitate decentralized trading.

Aave

Decentralized Finance (DeFi)

Aave

A DeFi platform for borrowing and lending cryptocurrency without intermediaries.

Uses Web3 to connect users to liquidity pools for decentralized borrowing and lending via smart contracts on Ethereum.

 

Homework of  Week2 - Guide to Interacting with a Smart Contract Using Truffle

Refer to:  https://github.com/wildmouse/practicing-Hands-On-Smart-Contract-Development-with-Solidity-and-Ethereum/tree/master/greeter

 

1. Setting Up the Environment

  1. Ensure Node.js and npm are Installed:
  2. Install Truffle:
    • Open your terminal and run:

npm install -g truffle

  1. Set Up a Truffle Project:
    • Create a new directory for your project and navigate into it:

mkdir my_truffle_project

cd my_truffle_project

    • Initialize a new Truffle project:

truffle init

 

2. Write and Compile the Smart Contract

  1. Create a Smart Contract:
    • In the contracts directory, create a new file named Greeter.sol:

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

 

contract Greeter {

    string public greeting;

 

constructor(string memory _greeting) {

        greeting = _greeting;

    }

 

    function greet() public view returns (string memory) {

        return greeting;

    }

}

  1. Create a Migration Script:
    • In the migrations directory, create a new file named 2_deploy_greeter.js:

const Greeter = artifacts.require("Greeter");

 

module.exports = function(deployer) {

deployer.deploy(Greeter, "Hello, JU!"); // Change greeting here

};

  1. Compile the Contract:
    • Run the following command in your terminal:

truffle compile

3. Deploy the Contract

  1. Start the Development Network:
    • Ensure Ganache or Truffle Develop is running. You can use Truffle Develop:

truffle develop

  1. Deploy the Contract:
    • In a new terminal window (while Truffle Develop is running), deploy the contract:

truffle migrate

4. Interact with the Contract Using a Script

  1. Create a scripts Folder:
    • Ensure there is a folder named scripts in the root directory of your project.
  2. Create a Script File:
    • In the scripts directory, create a file named scripts_test.js:

const Greeter = artifacts.require("Greeter");

 

module.exports = async function(callback) {

    try {

        // Get the deployed instance of the contract

        const instance = await Greeter.deployed();

 

        // Print the address of the deployed contract

console.log("Contract address:", instance.address);

 

        // Call the greet function

        const greeting = await instance.greet();

console.log("Greeting:", greeting);

 

    } catch (error) {

console.error(error);

    }

callback();

};

  1. Run the Script:
    • In your terminal, execute the script with Truffle:

truffle exec scripts/scripts_test.js

 

5. Troubleshooting

  • Ensure Ganache is Running:
    • Verify that Ganache or Truffle Develop is active when deploying and running scripts.
  • Check Truffle Configuration:
    • Ensure truffle-config.js is correctly set up for your network.
  • Reinstall Truffle:
    • If issues persist, try reinstalling Truffle globally:

npm uninstall -g truffle

npm install -g truffle

 

6. Example Output

When running the script, you should see:

Contract address: 0x... (your contract address)

Greeting: Hello, JU!

This guide covers the entire process from setting up the environment to interacting with your smart contract.

 

 

 

Homework of Week 3 - Interacting with a Smart Contract Using MetaMask, Ganache, and Remix

Step by Step Instructional Video Part I (Metamask)  .     Part II (Remix)  

Refer to  https://github.com/arshdeepbahga/blockchain-applications-book/tree/master/Chapter-5

1. Install and Set Up MetaMask

Why: MetaMask is a digital wallet used to manage accounts and interact with Ethereum-based applications. It acts as the bridge between the blockchain (Ganache) and the application (Remix).

  • Step:
    1. Go to the MetaMask website and install the MetaMask browser extension.
    2. After installation, click the MetaMask icon in your browser to open it.
    3. Set up a new wallet by following the on-screen instructions, and make sure to securely store your recovery phrase.
    4. Once the wallet is set up, you'll see your account in MetaMask with a default name like "Account 1."

Expected Outcome: MetaMask is installed and your first Ethereum account is created.

 

2. Set Up Ganache

Why: Ganache simulates a blockchain environment locally, allowing you to deploy and test smart contracts without using real money.

  • Step:
    1. Download and install Ganache from the Truffle Suite website.
    2. Open Ganache and click on “Quickstart Ethereum” to start a new workspace.
    3. Ganache will create 10 accounts with 100 ETH each, and it will run on a local network at http://127.0.0.1:7545.

Expected Outcome: Ganache is running locally, and you have access to 10 accounts with 100 ETH each.