/
WrappedERC721.sol
45 lines (36 loc) · 1.04 KB
/
WrappedERC721.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: MIT
pragma solidity 0.8.3;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
contract WrappedERC721 is ERC721Burnable, Ownable {
// Mapping from tokenID to metadata
mapping(uint256 => string) private _metadata;
constructor(string memory name, string memory symbol)
ERC721(name, symbol)
{}
function safeMint(
address to,
uint256 tokenId,
string memory metadata
) public onlyOwner {
_safeMint(to, tokenId);
_metadata[tokenId] = metadata;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"WrappedERC721: URI query for nonexistent token"
);
return _metadata[tokenId];
}
function burn(uint256 tokenId) public virtual override {
super.burn(tokenId);
delete _metadata[tokenId];
}
}