๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles

Hello developers ๐Ÿ‘‹

This is Day 2 of my 30 Days of Solidity Challenge where I share my learning journey while building small but useful smart contracts.

๐Ÿ“Œ Task for Today

Yesterday, we built a simple contract that stored just a userโ€™s nam…


This content originally appeared on DEV Community and was authored by Saurav Kumar

Hello developers ๐Ÿ‘‹

This is Day 2 of my 30 Days of Solidity Challenge where I share my learning journey while building small but useful smart contracts.

๐Ÿ“Œ Task for Today

Yesterday, we built a simple contract that stored just a userโ€™s name and bio.
Today, I enhanced that contract to make it feel more like a real user profile system.

We added extra fields like:

  • Username
  • Bio
  • Age
  • Location
  • Profile Picture (can be an IPFS hash or URL)
  • JoinedOn (timestamp when profile was created/updated)

๐Ÿ“ Smart Contract โ€“ Enhanced Profile

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract EnhancedProfile {
    struct Profile {
        string username;
        string bio;
        uint256 age;
        string location;
        string profilePic;  // could store IPFS hash or URL
        uint256 joinedOn;
    }

    mapping(address => Profile) private profiles;

    event ProfileUpdated(
        address indexed user,
        string username,
        string bio,
        uint256 age,
        string location,
        string profilePic
    );

    function setProfile(
        string memory _username,
        string memory _bio,
        uint256 _age,
        string memory _location,
        string memory _profilePic
    ) public {
        profiles[msg.sender] = Profile({
            username: _username,
            bio: _bio,
            age: _age,
            location: _location,
            profilePic: _profilePic,
            joinedOn: block.timestamp
        });

        emit ProfileUpdated(msg.sender, _username, _bio, _age, _location, _profilePic);
    }

    function getProfile(address _user)
        public
        view
        returns (
            string memory username,
            string memory bio,
            uint256 age,
            string memory location,
            string memory profilePic,
            uint256 joinedOn
        )
    {
        Profile memory profile = profiles[_user];
        return (
            profile.username,
            profile.bio,
            profile.age,
            profile.location,
            profile.profilePic,
            profile.joinedOn
        );
    }
}

๐Ÿ”Ž How It Works

  1. Struct Profile โ†’ Stores all user details.
  2. Mapping (address => Profile) โ†’ Each wallet address is linked to its profile.
  3. setProfile() โ†’ Users can create or update their profile.
  4. getProfile() โ†’ Anyone can fetch a profile by providing the wallet address.
  5. Event ProfileUpdated โ†’ Logs every update, useful for dApp frontends.

โšก Example Usage

  • A user saves their profile:
setProfile("Alice", "I build dApps", 25, "Bangalore, India", "ipfs://QmHashOfPic");
  • Anyone can retrieve Aliceโ€™s profile:
getProfile(aliceAddress);

โžก๏ธ Returns all details including the timestamp.

๐ŸŽฏ Learning Outcome

With this task, I learned how to:
โœ… Store multiple user details on-chain.
โœ… Use structs + mappings effectively.
โœ… Add events for tracking profile changes.
โœ… Design a basic identity system for future dApps.

This is a small but important step towards understanding data storage & retrieval in Solidity. Tomorrow, Iโ€™ll move to the next challenge and keep building!

๐Ÿ‘‰ You can also check out Day 1 blog here: Day 1 of Solidity Challenge โ€“ Click Counter

Stay tuned for Day 3 ๐Ÿš€

โœจ Thanks for reading! If youโ€™re also learning Solidity, letโ€™s connect and build together.


This content originally appeared on DEV Community and was authored by Saurav Kumar


Print Share Comment Cite Upload Translate Updates
APA

Saurav Kumar | Sciencx (2025-10-02T18:45:20+00:00) ๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles. Retrieved from https://www.scien.cx/2025/10/02/%f0%9f%9a%80-day-2-of-30-days-of-solidity-challenge-building-enhanced-user-profiles/

MLA
" » ๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles." Saurav Kumar | Sciencx - Thursday October 2, 2025, https://www.scien.cx/2025/10/02/%f0%9f%9a%80-day-2-of-30-days-of-solidity-challenge-building-enhanced-user-profiles/
HARVARD
Saurav Kumar | Sciencx Thursday October 2, 2025 » ๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles., viewed ,<https://www.scien.cx/2025/10/02/%f0%9f%9a%80-day-2-of-30-days-of-solidity-challenge-building-enhanced-user-profiles/>
VANCOUVER
Saurav Kumar | Sciencx - » ๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/02/%f0%9f%9a%80-day-2-of-30-days-of-solidity-challenge-building-enhanced-user-profiles/
CHICAGO
" » ๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles." Saurav Kumar | Sciencx - Accessed . https://www.scien.cx/2025/10/02/%f0%9f%9a%80-day-2-of-30-days-of-solidity-challenge-building-enhanced-user-profiles/
IEEE
" » ๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles." Saurav Kumar | Sciencx [Online]. Available: https://www.scien.cx/2025/10/02/%f0%9f%9a%80-day-2-of-30-days-of-solidity-challenge-building-enhanced-user-profiles/. [Accessed: ]
rf:citation
» ๐Ÿš€ Day 2 of 30 Days of Solidity Challenge โ€“ Building Enhanced User Profiles | Saurav Kumar | Sciencx | https://www.scien.cx/2025/10/02/%f0%9f%9a%80-day-2-of-30-days-of-solidity-challenge-building-enhanced-user-profiles/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.