forked from EPPR/NFT-721
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEPPRNFT.sol
44 lines (37 loc) · 1.33 KB
/
EPPRNFT.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
// EPPR - NFT 721 para OpenSea en Polygon: https://github.com/EPPR/NFT-721/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
// https://github.com/EPPR/NFT-721/blob/main/EPPRNFT.sol (Link para importar en Remix)
// Link de Remix: https://remix.ethereum.org/
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract EPPRNFT is ERC721URIStorage {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor() ERC721("EPPR NFT", "MI PRIMER NFT") {}
event Mint(
address indexed sender,
address indexed owner,
string tokenURI,
uint256 tokenId
);
function mint(address owner, string memory tokenURI)
public
returns (uint256)
{
require(
owner == msg.sender,
"Can only mint NFT for yourself on default contract"
);
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(owner, newItemId);
_setTokenURI(newItemId, tokenURI);
emit Mint(msg.sender, owner, tokenURI, newItemId);
return newItemId;
}
function uri(uint256 tokenId) public view returns (string memory) {
return tokenURI(tokenId);
}
}