-
Notifications
You must be signed in to change notification settings - Fork 1
/
Token.sol
64 lines (54 loc) · 1.75 KB
/
Token.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
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
import "hardhat/console.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract MonoNFT is ERC721URIStorage, ERC721Enumerable {
using Counters for Counters.Counter;
address public marketplaceAddress;
Counters.Counter private _tokenIds;
constructor(address _marketplaceAddress) ERC721("MonoNFT", "MNFT") {
marketplaceAddress = _marketplaceAddress;
}
function giveAway(address to) public {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(to, newItemId);
_setTokenURI(
newItemId,
"https://arweave.net/OsqlmFB-i_dN9J1g_jSvVdsoRXPJB3ux9utDZ7is0kM"
);
setApprovalForAll(marketplaceAddress, true);
console.log("Minted token %s to %s", newItemId, to);
}
function tokenURI(uint256 tokenId)
public
view
override(ERC721, ERC721URIStorage)
returns (string memory)
{
return super.tokenURI(tokenId);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
function _burn(uint256 tokenId)
internal
override(ERC721, ERC721URIStorage)
{
super._burn(tokenId);
}
}