🆔ProfileNFT.sol

as of June 19 2024

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

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

contract ProfileNFT is ERC721URIStorage, Ownable {
    uint256 private _tokenIdCounter;

    constructor() ERC721("ProfileNFT", "PNFT") {
        _tokenIdCounter = 1;
    }

    function mintProfile(address to, string memory uri) public onlyOwner {
        uint256 tokenId = _tokenIdCounter;
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
        _tokenIdCounter += 1;
    }

    function transferProfile(address from, address to, uint256 tokenId) public {
        require(ownerOf(tokenId) == from, "Not the owner");
        _transfer(from, to, tokenId);
    }
}

1. Profile NFT Contract

This contract allows users to own their own data in the form of NFTs.

Key Features:

  • Minting new profile NFTs.

  • Storing user data securely.

  • Allowing users to transfer ownership of their profile data.

Last updated