Professional Documents
Culture Documents
R009 BT Lab 7
R009 BT Lab 7
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.
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.
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.
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.