Skip to content

Commit 69a4dbc

Browse files
authored
Added ERC721 Contract
1 parent 3f83d14 commit 69a4dbc

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

Membership.sol

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// SPDX-License-Identifier: GPL-3.0
2+
pragma solidity ^ 0.8.0;
3+
4+
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
5+
import "@openzeppelin/contracts/access/Ownable.sol";
6+
import "@openzeppelin/contracts/utils/Counters.sol";
7+
8+
contract Minter is ERC721,Ownable{
9+
using Counters for Counters.Counter;
10+
//using String for uint;
11+
12+
Counters.Counter _ntokens;
13+
14+
constructor() ERC721("Minter","MN"){
15+
16+
}
17+
18+
mapping(address=>uint)minted;
19+
mapping(uint=>string)SetUris;
20+
21+
22+
struct TokenRender{
23+
uint id;
24+
string uri;
25+
26+
27+
}
28+
29+
30+
function getalltokens()public view returns(TokenRender[] memory){
31+
uint latestid = _ntokens.current();
32+
uint counter = 0;
33+
TokenRender[] result = new TokenRender[](latestid);
34+
35+
36+
for(uint i=0;i<latestid;i++){
37+
if(_exists(counter)){
38+
39+
string memory uri = tokenURI(counter);
40+
res[counter] = TokenRender(counter,uri);
41+
42+
}
43+
counter++;
44+
45+
}
46+
return result;
47+
48+
}
49+
50+
function seturi(uint id ,string memory uri)internal{
51+
SetUris[id] = uri;
52+
}
53+
54+
function tokenURI(uint token_id )public virtual override returns(string memory){
55+
string memory t_uri = SetUris[token_id];
56+
return t_uri;
57+
58+
}
59+
60+
function mint(address recipient, string memory uri ) public returns(uint){
61+
// current state of token ids;
62+
63+
uint newtoken = _ntokens.current();
64+
_ntokens.increment();
65+
_mint(recipient,newtoken);
66+
seturi(newtoken,uri);
67+
//minted[msg.sender] +=1;
68+
return newtoken;
69+
70+
}
71+
72+
73+
}

0 commit comments

Comments
 (0)