This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
FootiumPlayer.sol
133 lines (120 loc) · 4.1 KB
/
FootiumPlayer.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import {ERC2981Upgradeable} from "@openzeppelin/contracts-upgradeable/token/common/ERC2981Upgradeable.sol";
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
/**
* @title Footium Football Player Contract.
* @notice An NFT football player.
*/
contract FootiumPlayer is
ERC721Upgradeable,
AccessControlUpgradeable,
ERC2981Upgradeable,
PausableUpgradeable,
ReentrancyGuardUpgradeable,
OwnableUpgradeable
{
using CountersUpgradeable for CountersUpgradeable.Counter;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
CountersUpgradeable.Counter private _tokenIdCounter;
string private _base;
/**
* @notice Initializes the Footium Player contract.
* @param _receiver The royalty receiver address.
* @param _royaltyFeePercentage The royalty fee percentage (f.e. 500 means 5%).
* @param baseURI Token base metadata URI.
*/
function initialize(
address _receiver,
uint96 _royaltyFeePercentage,
string memory baseURI
) external initializer {
__ERC721_init("FootiumPlayer", "FFP");
__AccessControl_init();
__ERC2981_init();
__Pausable_init();
__ReentrancyGuard_init();
__Ownable_init();
_base = baseURI;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setDefaultRoyalty(_receiver, _royaltyFeePercentage);
}
/**
* @notice Mints a Footium football player.
* @param to The address that will receive the player.
* @param tokenId The ID of the club to be minted.
* @dev Only address with `MINTER_ROLE` can mint a token.
* @dev Can be executed when the contract is not paused.
*/
function safeMint(address to)
external
onlyRole(MINTER_ROLE)
nonReentrant
whenNotPaused
returns (uint256 tokenId)
{
tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to, tokenId);
}
/**
* @notice Returns token base metadata URI
*/
function _baseURI() internal view override returns (string memory) {
return _base;
}
/**
* @notice Sets the base metadata URI.
* @param baseURI New base metadata URI to be set.
* @dev Only the contract owner can set a new URI.
*/
function setBaseURI(string calldata baseURI) external onlyOwner {
_base = baseURI;
}
/**
* @notice Updates the royalty information.
* @param _receiver The royalty receiver address.
* @param _royaltyFeePercentage The royalty fee percentage (f.e. 500 means 5%).
* @dev Only owner address allowed.
*/
function setRoyaltyInfo(address _receiver, uint96 _royaltyFeePercentage)
external
onlyOwner
{
_setDefaultRoyalty(_receiver, _royaltyFeePercentage);
}
/**
* @notice Unpause the contract
* @dev Only owner address allowed.
*/
function activateContract() external onlyOwner {
_unpause();
}
/**
* @notice Pause the contract
* @dev Only owner address allowed.
*/
function pauseContract() external onlyOwner {
_pause();
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
override(
ERC721Upgradeable,
AccessControlUpgradeable,
ERC2981Upgradeable
)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}