🪪UserProfile.sol

User Ownership of data: an ERC-721 Token: User Profile NFT

UserProfile.sol

  • Design the Metadata: Each NFT has associated metadata that describes the unique attributes of the token. For a profile NFT, this could include the user's name, profile picture, and any other personal data they wish to include.

  • Implement ERC-721 Contract: Used the OpenZeppelin Contracts Wizard to generate an ERC-721 smart contract with desired features, including:

  • uriStorage to store and update the metadata URI. - burnable to allow users to burn their NFT and potentially erase their profile.

    mintable to allow the creation of new profile NFTs.

    pausable for emergency stop mechanisms. - access control to manage who can mint and administer the contract.

  • Create Front-End Interface: User interface that interacts with the smart contract, allowing users to mint their profile NFT and view their data.

Will give a breakdown of the codebase here after the Chainlink Block Magic Hackathon submission date June 2nd at 11:00pm

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

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract UserProfileNFT is ERC721, Ownable {
    uint256 public nextTokenId;
    mapping(address => uint256) public profiles;

    constructor() ERC721("UserProfileNFT", "UPNFT") {}

    function createProfile() external {
        require(profiles[msg.sender] == 0, "Profile already exists");
        uint256 tokenId = nextTokenId;
        _mint(msg.sender, tokenId);
        profiles[msg.sender] = tokenId;
        nextTokenId++;
    }
}
// i on you reviews - rosalone labs

altUserProfile.sol

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

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract UserProfile is ERC721, Ownable {
    uint256 public nextTokenId;
    mapping(uint256 => string) private _tokenURIs;

    constructor() ERC721("UserProfile", "UPRO") {
        nextTokenId = 1; // Initialize the next token ID to 1
    }

    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal {
        _tokenURIs[tokenId] = _tokenURI;
    }

    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        return _tokenURIs[tokenId];
    }

    function mintProfile(address to, string memory uri) public onlyOwner {
        uint256 tokenId = nextTokenId;
        _mint(to, tokenId);
        _setTokenURI(tokenId, uri);
        nextTokenId++;
    }
}
  • License Declaration: Specifies the SPDX license identifier to ensure compliance with open-source license requirements.

  • Pragma Directive: Specifies the version of Solidity used to compile the contract. Using `^0.8.0` means any version of 0.8.x is acceptable.

Last updated