🏭CompanyProfiles.sol

as of June 19 2024

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

contract CompanyProfiles {
    struct CompanyProfile {
        string name;
        string data;
        address owner;
        bool claimed;
    }

    mapping(uint256 => CompanyProfile) public profiles;
    uint256 private _profileCounter;

    event ProfileCreated(uint256 indexed profileId, string name, string data);
    event ProfileClaimed(uint256 indexed profileId, address indexed owner);

    constructor() {
        _profileCounter = 1;
    }

    function createProfile(string memory name, string memory data) public {
        profiles[_profileCounter] = CompanyProfile({
            name: name,
            data: data,
            owner: address(0),
            claimed: false
        });
        emit ProfileCreated(_profileCounter, name, data);
        _profileCounter += 1;
    }

    function claimProfile(uint256 profileId) public {
        CompanyProfile storage profile = profiles[profileId];
        require(!profile.claimed, "Profile already claimed");
        profile.owner = msg.sender;
        profile.claimed = true;
        emit ProfileClaimed(profileId, msg.sender);
    }

    function getProfile(uint256 profileId) public view returns (CompanyProfile memory) {
        return profiles[profileId];
    }
}

Company Profile Contract

This contract generates company profiles based on user input and stores them. Companies can claim their profiles.

Key Features:

  • Auto-generating profiles.

  • Allowing companies to claim ownership.

  • Handling unclaimed profiles.

Last updated