Meta-mask:
• MetaMask is a cryptocurrency wallet and gateway to blockchain applications, primarily focusing on Ethereum and compatible networks.
• It is available as a browser extension and a mobile app, enabling users to manage their digital assets securely and interact with decentralized applications (dApps) directly from their browser or mobile device. Here are its key features:
• Key features:
1. Wallet Functionality:
Securely store, send, and receive cryptocurrencies, including Ether (ETH) and ERC-20 tokens. Generate and manage private keys locally on the user's device.
2. Integration with dApps:
Easily connect to Ethereum-based dApps, such as DeFi platforms, NFT marketplaces, and gaming applications. Simplifies signing transactions and interacting with smart contracts.
3. Network Support:
Supports the Ethereum mainnet, testnets, and custom networks like Binance Smart Chain, Polygon, and Avalanche.
4. User-Friendly Interface:
Simple setup process and intuitive interface for managing assets and transactions.
5. Security:
Protects wallet access with passwords and recovery seed phrases. Users retain full control of their private keys and funds.
6. Customization:
Add and manage multiple accounts. Set gas fees and limits manually for transactions.
Crypto-wallet
• A crypto wallet is a digital tool that allows users to store, send, and receive cryptocurrencies securely.
• It serves as an interface to manage crypto assets and interact with blockchain networks. There are different types of crypto wallets, each with varying levels of security, accessibility, and functionality.
• Types
o Hot Wallets: Online wallets (e.g., MetaMask, Trust Wallet), convenient but less secure.
o Cold Wallets: Offline wallets (e.g., Ledger, paper wallets), highly secure.
Steps for Browser Extension:
1. Visit the Official MetaMask Website: Go to https://metamask.io/ and click on the "Download" button.
2. Select Your Browser: Choose your preferred browser (Chrome, Firefox, Brave, Edge, or Opera). This will redirect you to the MetaMask extension page in your browser's web store.
3. Add to Browser: Click on "Add to [Your Browser]" (e.g., "Add to Chrome") and then "Add Extension" when prompted.
4. MetaMask Welcome Page: Once installed, a new tab should open with the MetaMask welcome page. If not, look for the MetaMask fox icon (often a puzzle piece icon) in your browser's toolbar and click it.
5. Get Started: Click "Get Started" on the welcome page.
6. Create a Wallet: Since this is your first time, choose "Create a Wallet." (If you already have a wallet and want to import it, you would choose "Import Wallet" and provide your Secret Recovery Phrase).
7. Privacy Options: You'll be asked if you want to share anonymous usage data to help improve MetaMask. You can choose "I Agree" or "No Thanks."
8. Create Password: Create a strong password for your MetaMask wallet. This password will unlock the extension on your current device. Agree to the Terms of Use.
9. Secure Your Wallet (Secret Recovery Phrase): This is the most critical step.
You will be presented with a Secret Recovery Phrase (also known as a seed phrase or recovery phrase). This is a series of 12 words that acts as the master key to your wallet.
Write it down physically on a piece of paper and store it in a safe, private place, ideally in multiple locations. Do not store it digitally (e.g., in a text file, email, or cloud storage) where it could be hacked.
Never share this phrase with anyone. If someone gets this phrase, they will have full access to your funds. MetaMask will never ask you for your Secret Recovery Phrase.
10. Confirm Secret Recovery Phrase: MetaMask will ask you to re-enter the words in the correct order to confirm you've written them down correctly.
11. Wallet Created: Once confirmed, your MetaMask wallet is set up! You'll see your Ethereum address and your current balance.
...............
Experiment 2:Create your own wallet using Metamask and demonstrate the crypto transactions.
...............
Experiment 3:Installation of Ganache Truffle Unit.
Ganache:
• Ganache is a personal blockchain, also known as a blockchain emulator, that is part of the Truffle Suite
• Purpose: It is used as a development and testing tool, allowing developers to simulate a blockchain environment on their local machines.
• Key features:
o Local Testing Environment: Ganache provides a local, isolated environment for testing smart contracts without interacting with the real Ethereum network.
o Deterministic Behavior: It allows developers to simulate and test their dApps in a controlled and predictable environment.
o Fast Iteration: Ganache enables faster development cycles by allowing developers to quickly test and debug their code.
o Built-in Accounts and Funds: Ganache comes with pre-funded accounts, making it easy to start testing.
o Customizable: Ganache allows developers to customize the blockchain's behavior, such as setting block times and gas limits
Truffle:
• Truffle is a development environment, testing framework, and asset pipeline specifically designed for building decentralized applications (dApps) on the Ethereum Virtual Machine (EVM).
• Purpose: Truffle streamlines the entire blockchain development process, making it easier for developers to build, test, and deploy smart contract.
• Key features:
o Smart Contract Compilation: Truffle handles the compilation of Solidity smart contracts.
o Automated Testing: It provides tools for writing and running automated tests for smart contracts.
o Deployment & Migration: Truffle simplifies the deployment and management of smart contracts on various networks.
o Network Management: It allows developers to manage connections to different Ethereum networks, including local testing networks and public networks.
o Interactive Console: Truffle includes an interactive console for interacting with deployed smart contracts.
Steps to install Ganache Truffle unit:
1. Install Node.js
Both Truffle and Ganache requires Node.js
• Download Node.js from its official website
• Verify the Node.js version
2. Install Truffle:
• Run the following command in the terminal:
npm install –g truffle
• Verify version of truffle
3. Install Ganache
• Download Ganache from https://archive.trufflesuite.com/ganache/
• After downloading, open it and install it:
• Select required option: Quickstart selected
• We get 10 accounts each with 100 ETH (fake) and the blockchain starts running on http://127.0.0.1:8545.
Experiment 4: Write a program in solidity using Remix Editor for Bank transactions.
Solidity:
• Solidity is a brand-new programming language created by Ethereum.
• It is a high-level programming language designed for implementing smart contracts.
• It is a statically typed object-oriented (contract-oriented) language.
• Solidity is highly influenced by Python, c++, and JavaScript which run on the Ethereum Virtual Machine(EVM).
• Solidity supports complex user-defined programming, libraries, and inheritance.
• Solidity is the primary language for blockchains running platforms.
• Solidity can be used to create contracts like voting, blind auctions, crowdfunding, multi-signature wallets, etc.
Ethereum:
• Ethereum is a decentralized open-source platform based on the blockchain domain, used to run smart contracts i.e. applications that execute the program exactly as it was programmed without the possibility of any fraud, interference from a third party, censorship, or downtime.
• It serves as a platform for nearly 2,60,000 different cryptocurrencies.
• Ether is a cryptocurrency generated by Ethereum miners, used to reward for the computations performed to secure the blockchain.
Steps to Run Solidity Code:
1. Write Code: Use .sol files in the Remix editor
2. Compile: Use the "Solidity Compiler" tab to compile the code
3. Deploy: Go to "Deploy & Run Transactions" tab, choose environment:
a. JavaScript VM (Local simulation)
b. Injected Web3 (connects to Metamask)
c. Web3 Provider (e.g., Infura)
4. Interact: After deployment, use the UI buttons to call contract functions
Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Bank {
// Mapping to store balance of each user
mapping(address => uint) private balances;
// Event for logging deposits and withdrawals
event Deposit(address indexed user, uint amount);
event Withdraw(address indexed user, uint amount);
// Deposit function (payable)
function deposit() public payable {
require(msg.value > 0, "Deposit amount must be greater than 0");
balances[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}
// Withdraw function
function withdraw(uint _amount) public {
require(balances[msg.sender] >= _amount, "Insufficient balance");
// Deduct balance first to prevent re-entrancy attacks
balances[msg.sender] -= _amount;
// Send Ether back to user
payable(msg.sender).transfer(_amount);
emit Withdraw(msg.sender, _amount);
}
// Check balance function
function getBalance() public view returns (uint) {
return balances[msg.sender];
}
}
Experiment 5: Write a program to create Student data using Structure & arrays and deploy it.
Solidity:
• Solidity is a brand-new programming language created by Ethereum.
• It is a high-level programming language designed for implementing smart contracts.
• It is a statically typed object-oriented (contract-oriented) language.
• Solidity is highly influenced by Python, c++, and JavaScript which run on the Ethereum Virtual Machine(EVM).
• Solidity supports complex user-defined programming, libraries, and inheritance.
• Solidity is the primary language for blockchains running platforms.
• Solidity can be used to create contracts like voting, blind auctions, crowdfunding, multi-signature wallets, etc.
Ethereum:
• Ethereum is a decentralized open-source platform based on the blockchain domain, used to run smart contracts i.e. applications that execute the program exactly as it was programmed without the possibility of any fraud, interference from a third party, censorship, or downtime.
• It serves as a platform for nearly 2,60,000 different cryptocurrencies.
• Ether is a cryptocurrency generated by Ethereum miners, used to reward for the computations performed to secure the blockchain.
Steps to Run Solidity Code:
1. Write Code: Use .sol files in the Remix editor
2. Compile: Use the "Solidity Compiler" tab to compile the code
3. Deploy: Go to "Deploy & Run Transactions" tab, choose environment:
a. JavaScript VM (Local simulation)
b. Injected Web3 (connects to Metamask)
c. Web3 Provider (e.g., Infura)
4. Interact: After deployment, use the UI buttons to call contract functions
Structs in Solidity:
• structs in Solidity allow grouping related data types into a single custom type. They are useful for modeling real-world entities like students, employees, etc.
• Syntax:
struct Student {
uint id;
string name;
uint age;
Arrays in Solidity:
• Arrays in Solidity can be used to store a collection of data.
• We can use:
o Fixed-size arrays: Size is known and fixed during compilation.
o Dynamic arrays: Size can grow during execution.
Code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract StudentData {
// Struct to hold student details
struct Student {
uint id;
string name;
uint age;
}
// Array to store students
Student[] public students;
// Function to add a new student
function addStudent(uint _id, string memory _name, uint _age) public {
students.push(Student(_id, _name, _age));
}
// Function to get student count
function getStudentCount() public view returns (uint) {
return students.length;
}
// Fallback function to handle unexpected transactions
fallback() external payable {
// Accept ether but do nothing
}
// Receive function to handle plain ether transfers
receive() external payable {}
}
Experiment 6: Survey report for types of blockchain and its real time use cases.
Blockchain:
• Blockchain is a decentralized, distributed ledger technology that records transactions in a secure, transparent, and tamper-proof manner.
• It operates on a peer-to-peer (P2P) network, eliminating the need for a central authority.
• Transactions are grouped into blocks, which are cryptographically linked to form a chain, ensuring security and immutability.
• Each "block" contains data, and blocks are linked in a chronological "chain."
• Blockchain plays a crucial role in cryptocurrency systems, maintaining a secure and decentralized record of transactions, but they are not limited to cryptocurrency uses.
• Blockchains can be used to make data in any industry immutable—meaning it cannot be altered.
• Different types of information can be stored on a blockchain, but the most common use has been as a transaction ledger.
• In Bitcoin’s case, the blockchain is decentralized, so no single person or group has control—instead, all users collectively retain control.
Types of Blockchain:
1. Public Blockchain:
a. A public blockchain is a concept where anyone is free to join and take part in the core activities of the blockchain network.
b. Anyone can read, write, and audit the ongoing activities on a public blockchain network, which helps to achieve the self-determining, decentralized nature often authorized when blockchain is discussed.
c. Data on a public blockchain is secure as it is not possible to modify once they are validated.
d. Anyone can set his/her node or block in the network/ chain.
e. After a node or a block settles in the chain of the blocks, all the blocks are connected like peer-to-peer connections.
f. If someone tries to attack the block then it forms a copy of that data and it is accessible only by the original author of the block.
g. Consensus Mechanism: Proof of Work (PoW), Proof of Stake (PoS).
h. Examples: Bitcoin, Ethereum
Advantages:
• Decentralization: High level of decentralization, which reduces the risk of single points of failure and increases security.
• Transparency: All transactions are visible to anyone, enhancing transparency and trust.
• Immutability: Once data is recorded, it cannot be altered or deleted, providing a permanent record.
Disadvantages:
• Scalability Issues: Public blockchains often face scalability problems, with limited transaction throughput and slower processing times.
• Privacy Concerns: Public visibility of transactions may lead to privacy issues, as sensitive data can be exposed.
Real time use case:
• Cryptocurrencies: Bitcoin (BTC) for decentralized digital payments.
• Decentralized Finance (DeFi): Ethereum-based applications like Uniswap, Aave.
• NFT Marketplaces: OpenSea (Ethereum-based).
• Crowdfunding: ICOs (Initial Coin Offerings).
2. Private Blockchain:
a. Private blockchains are not like public blockchains it is managed by the entity that owns the network.
b. A trusted person is in charge of the running of the blockchain it will control who can access the private blockchain and also control the access rights of the private chain network.
c. It works based on permissions due to this it is also called a permission-based blockchain.
d. Only the entities participating in a transaction will know about it and the other stakeholders not be able to access it.
e. Consensus Mechanism: Practical Byzantine Fault Tolerance (PBFT), Raft.
Advassntages:
• Performance and Speed: Faster transaction processing and higher throughput compared to public blockchains due to fewer nodes and reduced consensus requirements.
• Privacy: Transactions and data are visible only to authorized participants, enhancing privacy.
Disadvantages:
• Centralization: Less decentralized than public blockchains, which can introduce single points of failure and reduce the security benefits.
• Limited Transparency: Reduced transparency can make it harder for external auditors to verify data.
Real time use cases:
• Supply Chain Management: IBM Food Trust used by Walmart.
• Finance & Banking: JPMorgan’s Quorum for interbank transfers.
• Healthcare: Storing and managing private patient records securely.
3. Consortium (federated) Blockchain:
a. A consortium blockchain is a concept where it is permissioned by the government and a group of organizations, not by one person like a private blockchain.
b. Consortium blockchains are more decentralized than private blockchains, due to being more decentralized it increases the privacy and security of the blocks.
c. Consortium blockchains lie between public and private blockchains.
d. They are designed by organizations and no one person outside of the organizations can gain access.
e. In Consortium blockchains all companies in between organizations collaborate equally.
Advantages:
• Efficiency: Better performance and efficiency than public blockchains due to fewer nodes and optimized consensus mechanisms.
• Shared Control: Governance is shared among consortium members, which can enhance trust and cooperation.
• Privacy and Security: Improved privacy and security compared to public blockchains, as access is restricted.
Disadvantages:
• Complex Governance: Decision-making can be complex due to multiple stakeholders with potentially conflicting interests.
• Less Decentralization: While more decentralized than private blockchains, consortium blockchains still have a limited number of participants, which can reduce some decentralization benefits.
• Interoperability: Challenges can arise when integrating with other blockchain networks or systems.
Real time use cases:
• Banking Sector: R3 Corda used by multiple banks for secure transactions.
• Trade & Logistics: TradeLens (IBM & Maersk) for digitizing shipping data.
• Energy Sector: Energy Web Chain for energy grid management.
4. Hybrid Blockchain:
• Hybrid blockchains combine elements of both public and private blockchains.
• They aim to offer the benefits of both types, allowing for controlled access and transparency.
• Examples include Dragonchain and IBM’s Food Trust.
Advantages:
• Flexibility: Offers the ability to balance transparency and privacy based on the needs of the organization or project.
• Scalability and Performance: Can be designed to optimize performance and scalability while maintaining some degree of transparency.
• Customizable Access: Allows organizations to control who can access certain data while making some data available to the public.
Disadvantages:
• Complexity: Implementation can be more complex due to the need to manage different access levels and integrations.
• Governance Challenges: Balancing governance between public and private aspects can be challenging.
• Potential for Confusion: This mayrequires lead to confusion among users and stakeholders about the nature and scope of access and transparency.