diff --git a/src/DCO2s.sol b/src/DCO2s.sol new file mode 100644 index 0000000..99beef7 --- /dev/null +++ b/src/DCO2s.sol @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity ^0.8.20; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; +import "@openzeppelin/contracts/access/AccessControl.sol"; + +/// @custom:security-contact david@neetsec.com +contract DCO2s is ERC721, ERC721Enumerable, AccessControl { + bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); + uint256 private _nextTokenId; + + constructor(address defaultAdmin, address minter) ERC721("DCO2s", "DCO2") { + _grantRole(DEFAULT_ADMIN_ROLE, defaultAdmin); + _grantRole(MINTER_ROLE, minter); + } + + function _baseURI() internal pure override returns (string memory) { + return "https://gateway.decentralizedscience.org/ipfs/"; + } + + function safeMint(address to) public onlyRole(MINTER_ROLE) { + uint256 tokenId = _nextTokenId++; + _safeMint(to, tokenId); + } + + // The following functions are overrides required by Solidity. + + function _update(address to, uint256 tokenId, address auth) + internal + override(ERC721, ERC721Enumerable) + returns (address) + { + return super._update(to, tokenId, auth); + } + + function _increaseBalance(address account, uint128 value) + internal + override(ERC721, ERC721Enumerable) + { + super._increaseBalance(account, value); + } + + function supportsInterface(bytes4 interfaceId) + public + view + override(ERC721, ERC721Enumerable, AccessControl) + returns (bool) + { + return super.supportsInterface(interfaceId); + } +}