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
- Struct Profile โ Stores all user details.
- Mapping (address => Profile) โ Each wallet address is linked to its profile.
- setProfile() โ Users can create or update their profile.
- getProfile() โ Anyone can fetch a profile by providing the wallet address.
- 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

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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.