Skip to content

Commit

Permalink
Create PIBankNFTRegistry.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jun 16, 2024
1 parent 11800b6 commit 188e4c7
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pragma solidity ^0.8.0;

import "./IPIBankNFTRegistry.sol";

contract PIBankNFTRegistry is IPIBankNFTRegistry {
mapping(uint256 => NFT) public nfts;
uint256 public nftCount;

struct NFT {
string uri;
address owner;
}

function mint(address _owner, string calldata _uri) public {
NFT memory nft = NFT(_uri, _owner);
nfts[nftCount] = nft;
nftCount++;
}

function burn(uint256 _nftId) public {
NFT storage nft = nfts[_nftId];
require(nft.owner == msg.sender, "Only the owner can burn");
delete nfts[_nftId];
}

function transfer(address _from, address _to, uint256 _nftId) public {
NFT storage nft = nfts[_nftId];
require(nft.owner == _from, "Invalid owner");
nft.owner = _to;
}

function ownerOf(uint256 _nftId) public view returns (address) {
NFT storage nft = nfts[_nftId];
return nft.owner;
}

function getNFT(uint256 _nftId) public view returns (string memory) {
NFT storage nft = nfts[_nftId];
return nft.uri;
}
}

0 comments on commit 188e4c7

Please sign in to comment.