Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Roll No.

: R009 Name: Aryan Bondgulwar


Program : MBA TECH AI Division: B
Batch:B1 Date of Experiment: 28-02-2024
Date of Submission: 06-02-24 Grade :

LAB 7
1. Constraints:

Define a constant MAX_SUPPLY representing the maximum supply of tokens in a token contract.
Use Case: Ensuring that the token supply does not exceed a predefined limit.
Implement a constant DECIMALS representing the number of decimal places for token values.
Use Case: Standardizing the precision of token values in a financial contract.

2. Immutable:
Create an immutable variable CREATION_TIME initialized to the block timestamp.
Use Case: Recording the exact time when a contract is deployed for auditing purposes.
Implement an immutable ADMIN_ADDRESS initialized to the owner's Ethereum address.
Use Case: Designating a specific address as the administrator with permanent privileges.

3. Counter:
Develop a contract with a counter that increments with each successful transaction.
Use Case: Tracking the number of interactions or transactions processed by a smart contract.
Create a contract with a counter that decrements with each withdrawal operation.
Use Case: Monitoring the number of withdrawals made from a user's account.

4. Signed and Unsigned Integers:


Define a signed integer variable balance to represent the account balance.
Use Case: Storing account balances in a financial application where negative balances are allowed.
Implement an unsigned integer variable totalSupply to represent the total supply of tokens.
Use Case: Managing the total quantity of tokens available in a token contract.
Since it is a testing environment we are not able to withdraw the funds hence further
transactions were not possible.

5. Boolean:
Design a contract with a boolean variable isPaused to control contract functionality.
Use Case: Allowing contract administrators to temporarily pause contract operations in case of
emergencies.
Create a contract with a boolean variable isVerified to indicate whether a user's identity is verified.
Use Case: Implementing a KYC (Know Your Customer) process in a decentralized application.

6. Addresses:
Implement an address variable owner to store the owner's Ethereum address.
Use Case: Identifying the owner or administrator of a smart contract.
Create a contract with an address variable recipient to specify the recipient of a transfer operation.
Use Case: Facilitating transfers of tokens or assets to specific Ethereum addresses.

7. Enums:
Define an enum named Status with values Active, Inactive, and Pending.
Use Case: Managing the status of user accounts or transactions within a system.
Implement an enum named Direction with values North, South, East, and
West. Use Case: Providing directional options in a location-based smart
contract.

8. Fixed and Dynamic Sized Arrays:


Create a fixed-size array scores to store the scores of participants in a competition.
Use Case: Recording and comparing scores in a gaming or sports-related smart contract.
Implement a dynamic-sized array names to store the names of registered users.
Use Case: Managing a list of users or participants with varying lengths in a decentralized application.

9. String Arrays:
Define a string array colors to store the names of different colors.
Use Case: Managing a list of color options in a graphical user interface or artistic application.
Implement a string array languages to store the names of programming languages.
Use Case: Providing language options for developers in a coding-related platform.
Since it is a testing environment we are not able to withdraw the funds hence further
transactions were not possible.

10. Structs:
Define a struct named Person with attributes name, age, and address.
Use Case: Storing personal information of users or individuals in a decentralized identity system.
Implement a struct named Product with attributes name, price, and quantity.
Use Case: Managing product details in an e-commerce or inventory management smart contract.

11. Mapping:
Create a mapping balances to store the token balances of Ethereum addresses.
Use Case: Maintaining account balances in a token contract for efficient lookup and management.
Implement a mapping votes to record the votes cast by users in an election.
Use Case: Facilitating voting processes and tallying results securely in a decentralized voting system.

12. Array Members:


Define a struct User with an array member permissions to store user access rights.
Use Case: Managing user permissions and roles in a permissioned blockchain network.
Implement a struct Playlist with an array member songs to store the list of songs in a playlist.
Use Case: Creating and managing playlists of songs in a decentralized music streaming
platform.

13. If-Else, If-Else If Conditions:


Develop a contract with conditional logic to check if a user's age meets a certain requirement for
access.
Use Case: Restricting access to certain features or content based on user age in a decentralized
platform.
Create a contract with multiple if-else conditions to determine the eligibility of a loan
applicant. Use Case: Evaluating loan applications and determining the terms based on various
criteria in a decentralized lending platform.

14. For Loop:


Implement a for loop to iterate over an array and calculate the total sum of its elements.
Use Case: Performing aggregation or calculation operations on array data in a smart contract.
Create a contract with a for loop to iterate over a range of numbers and perform a specific action.
Use Case: Implementing batch processing or repetitive tasks in a decentralized application.

15. While Loop:


Develop a contract with a while loop to continuously check for a specific condition before
proceeding. Use Case: Implementing iterative processes or state transitions based on dynamic
conditions in a smart contract.
Create a contract with a while loop to simulate a countdown timer with a delay between iterations.
Use Case: Implementing time-based functionalities or delays in a decentralized application.

16. Constructors:
Implement a constructor to initialize the owner's address and set initial parameters in a contract.
Use Case: Setting up contract parameters or configurations during deployment in a decentralized
system.
Create a constructor to initialize the token name, symbol, and initial supply in a token contract.
Use Case: Deploying and configuring a custom token with specific parameters in a decentralized
finance application.

Since it is a testing environment we are not able to withdraw the funds hence further
transactions were not possible.

You might also like