-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmint-character-sheet-nft.sol
156 lines (144 loc) · 5.12 KB
/
mint-character-sheet-nft.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
//Character Sheet Minter Contract
contract CharacterSheetNFTs is ERC721, Ownable {
using Counters for Counters.Counter;
using Strings for uint256;
Counters.Counter private _tokenIdCounter;
constructor() ERC721("Ceptor Club Character Sheet NFTs -test06", "CCCSt06") {}
function safeMint(address to) public {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to, tokenId);
tokenURI(tokenId);
}
//Values and Traits
string public cName;
string public cClass;
string public cSpecies;
string public cBackground;
string public cAlignment;
string public cDescr;
string public cPageLink;
string public cIMGURL;
//USE VRF To SEt THEse?
/*string public cStr;
string public cDex;
string public cInt;
string public cWis;
string public cCon;
string public cCha;
*/
/*
struct Traits {
string cStr;
string cDex;
string cInt;
string cWis;
string cCon;
string cCha;
}
*/
//await contract.methods.setValuesAndMint(cName, cClass, cSpecies, cBackground, cAlignment, cDescr, cPageLink, cIMGURL).send({
function setValuesAndMint(string memory _cName, string memory _cClass, string memory _cSpecies, string memory _cBackground, string memory _cAlignment, string memory _cDescr, string memory _cPageLink, string memory _cIMGURL) public{
cName = _cName;
cClass = _cClass;
cSpecies = _cSpecies;
cBackground = _cBackground;
cAlignment = _cAlignment;
cDescr = _cDescr;
cPageLink = _cPageLink;
cIMGURL = _cIMGURL;
/*
cStr = _cStr;
cDex = _cDex;
cInt = _cInt;
cWis = _cWis;
cCon = _cCon;
cCha = _cCha;
*/
safeMint(msg.sender);
}
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
bytes memory dataURI = abi.encodePacked(
'{',
'"name": "Ceptor Club Character #', tokenId.toString(), '"'',',
'"description": ''"', cDescr, '"',',',
'"external_url": ''"', cPageLink, '"',',',
'"image": ''"', cIMGURL, '"',',',
'"attributes":',
'[',
'{',
'"trait_type": "Character Name"'',',
'"value": ''"', cName, '"',
'}'',',
'{',
'"trait_type": "Character Class"'',',
'"value": ''"', cClass, '"',
'}'',',
'{',
'"trait_type": "Species"'',',
'"value": ''"', cSpecies, '"',
'}'',',
'{',
'"trait_type": "Background"'',',
'"value": ''"', cBackground, '"',
'}'',',
'{',
'"trait_type": "Alignment"'',',
'"value": ''"', cAlignment, '"',
'}',
//Remember this is a closing bracket.
/*
'{',
'"trait_type": "Strength"'',',
'"max_value": 30'',',
'"value": ', cStr,
'}'',',
'{',
'"trait_type": "Dexterity"'',',
'"max_value": 30'',',
'"value": ', cDex,
'}'',',
'{',
'"trait_type": "Intelligence"'',',
'"max_value": 30'',',
'"value": ', cInt,
'}'',',
'{',
'"trait_type": "Wisdom"'',',
'"max_value": 30'',',
'"value": ', cWis,
'}'',',
'{',
'"trait_type": "Constitution"'',',
'"max_value": 30'',',
'"value": ', cCon,
'}'',',
'{',
'"trait_type": "Charisma"'',',
'"max_value": 30'',',
'"value": ', cCha,
'}',
*/
']',
'}'
);
return string(
abi.encodePacked(
"data:application/json;base64,",
Base64.encode(dataURI)
)
);
}
}