Skip to content

Commit 9e33f52

Browse files
committed
testing
1 parent d356479 commit 9e33f52

29 files changed

+1905
-51
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,6 @@ dist
143143

144144
.DS_Store
145145

146-
build*
146+
build*
147+
# Local Netlify folder
148+
.netlify

backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"rarity_md": "node utils/functions/getRarity_fromMetadata",
1919
"rarity_rank": "node utils/functions/rarity_rank.js",
2020
"preview": "node utils/preview.js",
21+
"update_contract": "node utils/nftport/updateContract.js %npm_config_u%",
2122
"pixelate": "node utils/pixelate.js",
2223
"update_info": "node utils/update_info.js",
2324
"preview_gif": "node utils/preview_gif.js",

backend/src/config.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ const network = NETWORK.eth;
77

88
// General metadata for Ethereum
99
const namePrefix = "testSTACKr Collection";
10+
// const namePrefix = "YOUR COLLECTION NAME";
1011
const description = "Test collection description";
12+
// const description = "Remember to replace this description";
1113
const baseUri = "ipfs://NewUriToReplace"; // This will be replaced automatically
1214

1315
// If you have selected Solana then the collection starts from 0 automatically
1416
const layerConfigurations = [
1517
{
16-
growEditionSizeTo: 20,
18+
growEditionSizeTo: 5,
1719
layersOrder: [
1820
{ name: "Background" },
1921
{ name: "Eyeball" },
@@ -41,38 +43,43 @@ const extraMetadata = {
4143
};
4244

4345
// NFTPort Info
46+
4447
// ** REQUIRED **
4548
const AUTH = "cd604374-c889-404a-b6e7-cdb0dcb1e892";
4649
// const AUTH = "YOUR API KEY HERE";
4750
const LIMIT = 2; // Your API key rate limit
51+
const CHAIN = 'rinkeby'; // only rinkeby or polygon
4852
const CONTRACT_NAME = 'testSTACKr Collection';
4953
const CONTRACT_SYMBOL = 'TSC';
54+
const METADATA_UPDATABLE = true; // set to false if you don't want to allow metadata updates after minting
5055
const OWNER_ADDRESS = '0xd8B808A887326F45B2D0cd999709Aa6264CeF919';
5156
// const OWNER_ADDRESS = 'YOUR WALLET ADDRESS HERE';
5257
const TREASURY_ADDRESS = '0xd8B808A887326F45B2D0cd999709Aa6264CeF919';
5358
// const TREASURY_ADDRESS = 'TREASURY WALLET ADDRESS HERE';
5459
const MAX_SUPPLY = 5000; // The maximum number of NFTs that can be minted. CANNOT BE UPDATED!
55-
const MINT_PRICE = 10; // Minting price per NFT in MATIC. CANNOT BE UPDATED!
60+
const MINT_PRICE = .001; // Minting price per NFT. Rinkeby = ETH, Polygon = MATIC. CANNOT BE UPDATED!
5661
const TOKENS_PER_MINT = 10; // maximum number of NFTs a user can mint in a single transaction. CANNOT BE UPDATED!
57-
const PUBLIC_MINT_START_DATE = null;
58-
const PRESALE_MINT_START_DATE = null;
59-
const CHAIN = 'rinkeby';
60-
const METADATA_UPDATABLE = true; // set to false if you don't want to allow metadata updates after minting
62+
const PUBLIC_MINT_START_DATE = "2022-03-20T11:30:48+00:00"; // This is required. Eg: 2022-02-08T11:30:48+00:00
63+
const PRESALE_MINT_START_DATE = "2022-03-13T11:30:48+00:00"; // delete
64+
// const PRESALE_MINT_START_DATE = null; // Optional. Eg: 2022-02-08T11:30:48+00:00
6165
const ROYALTY_SHARE = 1000; // Percentage of the token price that goes to the royalty address. 100 bps = 1%
6266
const ROYALTY_ADDRESS = "0xd8B808A887326F45B2D0cd999709Aa6264CeF919"; // Address that will receive the royalty
63-
const BASE_URI = null;
64-
const PREREVEAL_TOKEN_URI = null;
67+
const BASE_URI = null; // only update if you want to manually set the base uri
68+
const PREREVEAL_TOKEN_URI = null; // only update if you want to manually set the prereveal token uri
69+
const PRESALE_WHITELISTED_ADDRESSES = []; // only update if you want to manually set the whitelisted addresses
70+
6571
// ** OPTIONAL **
6672
let CONTRACT_ADDRESS = "YOUR CONTRACT ADDRESS"; // If you want to manually include it
6773
// Generic Metadata is optional if you want to reveal your NFTs
6874
const GENERIC = true; // Set to true if you want to upload generic metas and reveal the real NFTs in the future
69-
const GENERIC_TITLE = "Unknown"; // Replace with what you want the generic titles to say.
75+
// const GENERIC = false; // Set to true if you want to upload generic metas and reveal the real NFTs in the future
76+
const GENERIC_TITLE = CONTRACT_NAME; // Replace with what you want the generic titles to say if you want it to be different from the contract name.
7077
const GENERIC_DESCRIPTION = "Unknown"; // Replace with what you want the generic descriptions to say.
71-
const GENERIC_IMAGE = [
72-
"https://ipfs.io/ipfs/QmUf9tDbkqnfHkQaMdFWSGAeXwVXWA61pFED7ypx4hcsfh",
73-
]; // Replace with your generic image(s). If multiple, separate with a comma.
74-
const REVEAL_PROMPT = true; // Set to false if you want to disable the prompt to confirm each reveal.
75-
const INTERVAL = 900000; // Milliseconds. This is the interval for it to check for sales and reveal the NFT. 900000 = 15 minutes.
78+
const GENERIC_IMAGE = "https://ipfs.io/ipfs/QmUf9tDbkqnfHkQaMdFWSGAeXwVXWA61pFED7ypx4hcsfh"; // Replace with your generic image that will display for all NFTs pre-reveal.
79+
80+
81+
// const REVEAL_PROMPT = true; // Set to false if you want to disable the prompt to confirm each reveal.
82+
// const INTERVAL = 900000; // Milliseconds. This is the interval for it to check for sales and reveal the NFT. 900000 = 15 minutes.
7683

7784
// Automatically set contract address if deployed using the deployContract.js script
7885
try {
@@ -183,7 +190,6 @@ module.exports = {
183190
INTERVAL,
184191
CONTRACT_NAME,
185192
CONTRACT_SYMBOL,
186-
CONTRACT_TYPE,
187193
REVEAL_PROMPT,
188194
METADATA_UPDATABLE,
189195
ROYALTY_SHARE,
@@ -194,5 +200,6 @@ module.exports = {
194200
PRESALE_MINT_START_DATE,
195201
PUBLIC_MINT_START_DATE,
196202
BASE_URI,
197-
PREREVEAL_TOKEN_URI
203+
PREREVEAL_TOKEN_URI,
204+
PRESALE_WHITELISTED_ADDRESSES
198205
};

backend/utils/functions/fetchWithRetry.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@ const basePath = process.cwd();
22
const fetch = require("node-fetch");
33
const { AUTH } = require(`${basePath}/src/config.js`);
44

5+
function fetchNoRetry(url, options) {
6+
return new Promise((resolve, reject) => {
7+
options.headers.Authorization = AUTH;
8+
9+
fetch(url, options)
10+
.then((res) => {
11+
const status = res.status;
12+
13+
if (status === 200) {
14+
return res.json();
15+
} else {
16+
throw `ERROR STATUS: ${status}`;
17+
}
18+
})
19+
.then((json) => {
20+
if (json.response === "OK") {
21+
return resolve(json);
22+
} else {
23+
throw `NOK: ${json.error}`;
24+
}
25+
})
26+
.catch((error) => {
27+
console.error(`CATCH ERROR: ${error}`);
28+
console.log("Retrying");
29+
fetch_retry();
30+
});
31+
});
32+
}
33+
534
function fetchWithRetry(url, options) {
635
return new Promise((resolve, reject) => {
736
const fetch_retry = () => {
@@ -34,4 +63,4 @@ function fetchWithRetry(url, options) {
3463
});
3564
}
3665

37-
module.exports = { fetchWithRetry };
66+
module.exports = { fetchNoRetry, fetchWithRetry };

backend/utils/nftport/deployContract.js

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ const yesno = require('yesno');
66
const {
77
fetchWithRetry,
88
} = require(`${basePath}/utils/functions/fetchWithRetry.js`);
9-
const {
9+
let {
1010
CHAIN,
11+
GENERIC,
1112
CONTRACT_NAME,
1213
CONTRACT_SYMBOL,
13-
CONTRACT_TYPE,
1414
METADATA_UPDATABLE,
1515
ROYALTY_SHARE,
1616
ROYALTY_ADDRESS,
1717
MAX_SUPPLY,
1818
MINT_PRICE,
19+
TOKENS_PER_MINT,
1920
OWNER_ADDRESS,
2021
TREASURY_ADDRESS,
2122
PUBLIC_MINT_START_DATE,
@@ -35,12 +36,45 @@ const deployContract = async () => {
3536
process.exit(0);
3637
}
3738

39+
if(GENERIC) {
40+
try {
41+
let jsonFile = fs.readFileSync(`${basePath}/build/ipfsMetasGeneric/_ipfsMetasResponse.json`);
42+
let metaData = JSON.parse(jsonFile);
43+
if(metaData.response === "OK" && metaData.error === null) {
44+
if(!PREREVEAL_TOKEN_URI) {
45+
PREREVEAL_TOKEN_URI = metaData.metadata_uri;
46+
}
47+
} else {
48+
console.log('There is an issue with the metadata upload. Please check the /build/_ipfsMetasGeneric/_ipfsMetasResponse.json file for more information. Running "npm run upload_metadata" may fix this issue.');
49+
}
50+
} catch (err) {
51+
console.log(`/build/_ipfsMetasGeneric/_ipfsMetasResponse.json file not found. Run "npm run upload_metadata" first.`);
52+
console.log(`Catch: ${err}`);
53+
process.exit(0);
54+
}
55+
} else {
56+
try {
57+
let jsonFile = fs.readFileSync(`${basePath}/build/ipfsMetas/_ipfsMetasResponse.json`);
58+
let metaData = JSON.parse(jsonFile);
59+
if(metaData.response === "OK" && metaData.error === null) {
60+
if(!BASE_URI) {
61+
BASE_URI = metaData.metadata_directory_ipfs_uri;
62+
}
63+
} else {
64+
console.log('There is an issue with the metadata upload. Please check the /build/_ipfsMetas/_ipfsMetasResponse.json file for more information. Running "npm run upload_metadata" may fix this issue.');
65+
}
66+
} catch (err) {
67+
console.log(`/build/_ipfsMetasGeneric/_ipfsMetasResponse.json file not found. Run "npm run upload_metadata" first.`);
68+
process.exit(0);
69+
}
70+
}
71+
3872
if (!fs.existsSync(path.join(`${basePath}/build`, "/contract"))) {
3973
fs.mkdirSync(path.join(`${basePath}/build`, "contract"));
4074
}
4175

4276
try {
43-
const url = `https://api.nftport.xyz/v0/contracts`;
77+
const url = `https://api.nftport.xyz/v0/contracts/collections`;
4478
const contract = {
4579
chain: CHAIN.toLowerCase(),
4680
name: CONTRACT_NAME,
@@ -68,12 +102,13 @@ const deployContract = async () => {
68102
const response = await fetchWithRetry(url, options);
69103
fs.writeFileSync(`${basePath}/build/contract/_deployContractResponse.json`, JSON.stringify(response, null, 2));
70104
if(response.response === "OK") {
71-
console.log(`Contract ${CONTRACT_NAME} deployment started.`);
105+
console.log(`Contract deployment started.`);
72106
} else {
73-
console.log(`Contract ${CONTRACT_NAME} deployment failed`);
107+
console.log(`Contract deployment failed`);
74108
}
109+
console.log(`Check /build/contract/_deployContractResponse.json for more information. Run "npm run get_contract" to get the contract details.`);
75110
} catch (error) {
76-
console.log(`CATCH: Contract ${CONTRACT_NAME} deployment failed`, `ERROR: ${error}`);
111+
console.log(`CATCH: Contract deployment failed`, `ERROR: ${error}`);
77112
}
78113
};
79114

backend/utils/nftport/genericMetas.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,20 @@ if (!fs.existsSync(path.join(buildDir, "/genericJson"))) {
1313
fs.mkdirSync(path.join(buildDir, "/genericJson"));
1414
}
1515

16-
let rawdata = fs.readFileSync(`${buildDir}/json/_metadata.json`);
17-
let data = JSON.parse(rawdata);
18-
1916
console.log("Starting generic metadata creation.");
2017

21-
for (let item of data) {
22-
const genericImage = GENERIC_IMAGE[Math.floor(Math.random() * GENERIC_IMAGE.length)];
23-
item.name = `${GENERIC_TITLE} #${item.edition}`;
24-
item.description = GENERIC_DESCRIPTION;
25-
item.image = genericImage;
26-
delete item.attributes;
27-
delete item.dna;
28-
29-
fs.writeFileSync(
30-
`${buildDir}/genericJson/${item.edition}.json`,
31-
JSON.stringify(item, null, 2)
32-
);
33-
34-
console.log(`${item.name} copied and updated!`);
18+
const genericObject = {
19+
"name": GENERIC_TITLE,
20+
"description": GENERIC_DESCRIPTION,
21+
"image": GENERIC_IMAGE,
22+
"external_url": "https://codecats.xyz",
23+
"date": 1647039293429,
24+
"compiler": "HashLips Art Engine - codeSTACKr Modified"
3525
}
3626

3727
fs.writeFileSync(
3828
`${buildDir}/genericJson/_metadata.json`,
39-
JSON.stringify(data, null, 2)
29+
JSON.stringify(genericObject, null, 2)
4030
);
4131

4232
console.log("Generic metadata created!");
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
const basePath = process.cwd();
2+
const yesno = require('yesno');
3+
let [UPDATE] = process.argv.slice(2);
4+
5+
const {
6+
fetchNoRetry,
7+
} = require(`${basePath}/utils/functions/fetchWithRetry.js`);
8+
let {
9+
CHAIN,
10+
PUBLIC_MINT_START_DATE,
11+
PRESALE_MINT_START_DATE,
12+
CONTRACT_ADDRESS,
13+
BASE_URI,
14+
PREREVEAL_TOKEN_URI,
15+
ROYALTY_SHARE,
16+
ROYALTY_ADDRESS,
17+
PRESALE_WHITELISTED_ADDRESSES
18+
} = require(`${basePath}/src/config.js`);
19+
20+
const contract = {
21+
chain: CHAIN.toLowerCase(),
22+
contract_address: CONTRACT_ADDRESS,
23+
};
24+
let updateValue = '';
25+
26+
switch (UPDATE) {
27+
case "public_mint_start_date":
28+
contract.public_mint_start_date = PUBLIC_MINT_START_DATE;
29+
updateValue = PUBLIC_MINT_START_DATE;
30+
break;
31+
case "presale_mint_start_date":
32+
contract.presale_mint_start_date = PRESALE_MINT_START_DATE;
33+
updateValue = PRESALE_MINT_START_DATE;
34+
break;
35+
case "presale_whitelisted_addresses":
36+
contract.presale_whitelisted_addresses = PRESALE_WHITELISTED_ADDRESSES;
37+
updateValue = PRESALE_WHITELISTED_ADDRESSES;
38+
break;
39+
case "royalty_share":
40+
contract.royalty_share = ROYALTY_SHARE;
41+
updateValue = ROYALTY_SHARE;
42+
break;
43+
case "royalty_address":
44+
contract.royalty_address = ROYALTY_ADDRESS;
45+
updateValue = ROYALTY_ADDRESS;
46+
break;
47+
case "contract_address":
48+
contract.contract_address = CONTRACT_ADDRESS;
49+
updateValue = CONTRACT_ADDRESS;
50+
break;
51+
case "base_uri":
52+
contract.base_uri = BASE_URI;
53+
updateValue = BASE_URI;
54+
break;
55+
case "prereveal_token_uri":
56+
contract.prereveal_token_uri = PREREVEAL_TOKEN_URI;
57+
updateValue = PREREVEAL_TOKEN_URI;
58+
break;
59+
default:
60+
console.log("Invalid update statement. Exiting...");
61+
process.exit(0);
62+
}
63+
64+
const updateContract = async () => {
65+
const ok = await yesno({
66+
question: `Updating ${UPDATE} to ${updateValue}, correct? (y/n):`,
67+
default: null,
68+
});
69+
70+
if(!ok) {
71+
console.log("Exiting...");
72+
process.exit(0);
73+
}
74+
75+
try {
76+
const url = `https://api.nftport.xyz/v0/contracts/collections`;
77+
const options = {
78+
method: "PUT",
79+
headers: {
80+
"Content-Type": "application/json",
81+
},
82+
body: JSON.stringify(contract),
83+
};
84+
const response = await fetchNoRetry(url, options);
85+
if(response.response === "OK") {
86+
console.log(`Contract Updated!`);
87+
} else {
88+
console.log(`Contract update failed!`);
89+
}
90+
} catch (error) {
91+
console.log(`CATCH: Contract update failed!`, `ERROR: ${error}`);
92+
}
93+
};
94+
95+
updateContract();

0 commit comments

Comments
 (0)