Solidity, a high-level language for writing smart contracts on platforms like Celo, provides various data types and features to handle complex tasks. This challenge emphasizes utilizing mappings and addresses in Solidity for effective data management.
Create a contract that manages user profiles on a mock social network platform. The contract should have the following features:
- It should allow a user to create a profile using their address.
- The profile should include details such as username, first name, and last name.
- It should prevent an address from creating more than one profile.
- The contract should include a function to update the profile details.
- The contract should allow retrieving the profile details of a user using their address.
- Implement a function to check if a user profile exists or not.
- Use Solidity’s
mappingkeyword to map an address to a profile.
- Create a
structto store user profile details.
msg.senderglobal variable can be used to associate a profile with an address.
require()function can be utilized to enforce rules such as one-profile-per-address.
- Correctness: The contract should compile without errors and meet all requirements.
- Readability: The contract should be well-documented, with comments explaining the code.
- Testability: You should also provide examples of how to test each function of the contract.
Remember, this challenge mainly focuses on data management using mappings and addresses and doesn’t cover other important aspects like security and gas optimization, which are crucial for real-world applications on the Celo platform.
For a comprehensive understanding of Celo smart contracts and Solidity, please refer to the Celo and Solidity tutorials.
Please reply with a link to your PR on https://github.com/celo-academy/Mapping-and-Address-Management-in-Solidity-Coding-Challenge, including your user profile management contract. Also, include any notes or comments you think are necessary to understand your design and choices. Lastly, provide a brief explanation about how each function of the contract should be tested.