|
1 | 1 | // SPDX-License-Identifier: Apache-2.0 |
2 | | -pragma solidity ^0.8.0; |
| 2 | +pragma solidity ^0.8.19; |
3 | 3 |
|
4 | | -/// @author thirdweb |
| 4 | +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; |
| 5 | +import "@openzeppelin/contracts/access/Ownable.sol"; |
| 6 | +import "./ContractMetadata.sol"; |
5 | 7 |
|
6 | | -import "./interface/IContractMetadata.sol"; |
| 8 | +contract RebelByNature is ERC721URIStorage, Ownable, ContractMetadata { |
| 9 | + uint256 public nextTokenId; |
7 | 10 |
|
8 | | -/** |
9 | | - * @title Contract Metadata |
10 | | - * @notice Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI |
11 | | - * for you contract. |
12 | | - * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. |
13 | | - */ |
| 11 | + event TributeMinted(uint256 tokenId, address recipient, uint256 timestamp); |
14 | 12 |
|
15 | | -abstract contract ContractMetadata is IContractMetadata { |
16 | | - /// @dev The sender is not authorized to perform the action |
17 | | - error ContractMetadataUnauthorized(); |
| 13 | + constructor() ERC721("Rebel By Nature", "SEQREB") {} |
18 | 14 |
|
19 | | - /// @notice Returns the contract metadata URI. |
20 | | - string public override contractURI; |
21 | | - |
22 | | - /** |
23 | | - * @notice Lets a contract admin set the URI for contract-level metadata. |
24 | | - * @dev Caller should be authorized to setup contractURI, e.g. contract admin. |
25 | | - * See {_canSetContractURI}. |
26 | | - * Emits {ContractURIUpdated Event}. |
27 | | - * |
28 | | - * @param _uri keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") |
29 | | - */ |
30 | | - function setContractURI(string memory _uri) external override { |
31 | | - if (!_canSetContractURI()) { |
32 | | - revert ContractMetadataUnauthorized(); |
33 | | - } |
34 | | - |
35 | | - _setupContractURI(_uri); |
| 15 | + function mintTribute(address recipient) external onlyOwner { |
| 16 | + uint256 tokenId = nextTokenId++; |
| 17 | + _mint(recipient, tokenId); |
| 18 | + _setTokenURI(tokenId, contractURI); |
| 19 | + emit TributeMinted(tokenId, recipient, block.timestamp); |
36 | 20 | } |
37 | 21 |
|
38 | | - /// @dev Lets a contract admin set the URI for contract-level metadata. |
39 | | - function _setupContractURI(string memory _uri) internal { |
40 | | - string memory prevURI = contractURI; |
41 | | - contractURI = _uri; |
42 | | - |
43 | | - emit ContractURIUpdated(prevURI, _uri); |
| 22 | + function _canSetContractURI() internal view override returns (bool) { |
| 23 | + return msg.sender == owner(); |
44 | 24 | } |
45 | | - |
46 | | - /// @dev Returns whether contract metadata can be set in the given execution context. |
47 | | - function _canSetContractURI() internal view virtual returns (bool); |
48 | 25 | } |
0 commit comments