Skip to content

Commit 4149f26

Browse files
authored
Merge pull request #134 from HashLips/dev
Solana metadata update
2 parents 1e3fa1a + 7b7ba01 commit 4149f26

File tree

6 files changed

+97
-11
lines changed

6 files changed

+97
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const layerConfigurations = [
126126
name: "Eye color",
127127
options: {
128128
blend: MODE.destinationIn,
129-
opcacity: 0.2,
129+
opacity: 0.2,
130130
displayName: "Awesome Eye Color",
131131
},
132132
},

constants/network.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
3+
const NETWORK = {
4+
eth: "eth",
5+
sol: "sol",
6+
};
7+
8+
module.exports = {
9+
NETWORK,
10+
};

layers/.DS_Store

0 Bytes
Binary file not shown.

src/config.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,28 @@ const path = require("path");
44
const isLocal = typeof process.pkg === "undefined";
55
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
66
const { MODE } = require(path.join(basePath, "constants/blend_mode.js"));
7-
const description =
8-
"This is the description of your NFT project, remember to replace this";
7+
const { NETWORK } = require(path.join(basePath, "constants/network.js"));
8+
9+
const network = NETWORK.eth;
10+
11+
// General metadata for Ethereum
12+
const namePrefix = "Your Collection";
13+
const description = "Remember to replace this description";
914
const baseUri = "ipfs://NewUriToReplace";
1015

16+
const solanaMetadata = {
17+
symbol: "NOC",
18+
seller_fee_basis_points: 1000, // Define how much % you want from secondary market sales 1000 = 10%
19+
external_url: "https://www.youtube.com/c/hashlipsnft",
20+
creators: [
21+
{
22+
address: "7fXNuer5sbZtaTEPhtJ5g5gNtuyRoKkvxdjEjEnPN4mC",
23+
share: 100,
24+
},
25+
],
26+
};
27+
28+
// If you have selected Solana then the collection starts from 0 automatically
1129
const layerConfigurations = [
1230
{
1331
growEditionSizeTo: 5,
@@ -83,4 +101,7 @@ module.exports = {
83101
extraMetadata,
84102
pixelFormat,
85103
text,
104+
namePrefix,
105+
network,
106+
solanaMetadata,
86107
};

src/main.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const path = require("path");
44
const isLocal = typeof process.pkg === "undefined";
55
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
6+
const { NETWORK } = require(path.join(basePath, "constants/network.js"));
67
const fs = require("fs");
78
const sha1 = require(path.join(basePath, "/node_modules/sha1"));
89
const { createCanvas, loadImage } = require(path.join(
@@ -23,6 +24,9 @@ const {
2324
debugLogs,
2425
extraMetadata,
2526
text,
27+
namePrefix,
28+
network,
29+
solanaMetadata,
2630
} = require(path.join(basePath, "/src/config.js"));
2731
const canvas = createCanvas(format.width, format.height);
2832
const ctx = canvas.getContext("2d");
@@ -118,16 +122,42 @@ const drawBackground = () => {
118122
const addMetadata = (_dna, _edition) => {
119123
let dateTime = Date.now();
120124
let tempMetadata = {
121-
dna: sha1(_dna),
122-
name: `#${_edition}`,
125+
name: `${namePrefix} #${_edition}`,
123126
description: description,
124127
image: `${baseUri}/${_edition}.png`,
128+
dna: sha1(_dna),
125129
edition: _edition,
126130
date: dateTime,
127131
...extraMetadata,
128132
attributes: attributesList,
129133
compiler: "HashLips Art Engine",
130134
};
135+
if (network == NETWORK.sol) {
136+
tempMetadata = {
137+
//Added metadata for solana
138+
name: tempMetadata.name,
139+
symbol: solanaMetadata.symbol,
140+
description: tempMetadata.description,
141+
//Added metadata for solana
142+
seller_fee_basis_points: solanaMetadata.seller_fee_basis_points,
143+
image: `image.png`,
144+
//Added metadata for solana
145+
external_url: solanaMetadata.external_url,
146+
edition: _edition,
147+
...extraMetadata,
148+
attributes: tempMetadata.attributes,
149+
properties: {
150+
files: [
151+
{
152+
uri: "image.png",
153+
type: "image/png",
154+
},
155+
],
156+
category: "image",
157+
creators: solanaMetadata.creators,
158+
},
159+
};
160+
}
131161
metadataList.push(tempMetadata);
132162
attributesList = [];
133163
};
@@ -254,7 +284,7 @@ const startCreating = async () => {
254284
let failedCount = 0;
255285
let abstractedIndexes = [];
256286
for (
257-
let i = 1;
287+
let i = network == NETWORK.sol ? 0 : 1;
258288
i <= layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo;
259289
i++
260290
) {

utils/update_info.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,32 @@
33
const path = require("path");
44
const isLocal = typeof process.pkg === "undefined";
55
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
6+
const { NETWORK } = require(path.join(basePath, "constants/network.js"));
67
const fs = require("fs");
78

89
console.log(path.join(basePath, "/src/config.js"));
9-
const { baseUri, description } = require(path.join(basePath, "/src/config.js"));
10+
const {
11+
baseUri,
12+
description,
13+
namePrefix,
14+
network,
15+
solanaMetadata,
16+
} = require(path.join(basePath, "/src/config.js"));
1017

1118
// read json data
1219
let rawdata = fs.readFileSync(`${basePath}/build/json/_metadata.json`);
1320
let data = JSON.parse(rawdata);
1421

1522
data.forEach((item) => {
16-
item.description = description;
17-
item.image = `${baseUri}/${item.edition}.png`;
23+
if (network == NETWORK.sol) {
24+
item.name = `${namePrefix} #${item.edition}`;
25+
item.description = description;
26+
item.creators = solanaMetadata.creators;
27+
} else {
28+
item.name = `${namePrefix} #${item.edition}`;
29+
item.description = description;
30+
item.image = `${baseUri}/${item.edition}.png`;
31+
}
1832
fs.writeFileSync(
1933
`${basePath}/build/json/${item.edition}.json`,
2034
JSON.stringify(item, null, 2)
@@ -26,5 +40,16 @@ fs.writeFileSync(
2640
JSON.stringify(data, null, 2)
2741
);
2842

29-
console.log(`Updated baseUri for images to ===> ${baseUri}`);
30-
console.log(`Updated description for images to ===> ${description}`);
43+
if (network == NETWORK.sol) {
44+
console.log(`Updated description for images to ===> ${description}`);
45+
console.log(`Updated name prefix for images to ===> ${namePrefix}`);
46+
console.log(
47+
`Updated creators for images to ===> ${JSON.stringify(
48+
solanaMetadata.creators
49+
)}`
50+
);
51+
} else {
52+
console.log(`Updated baseUri for images to ===> ${baseUri}`);
53+
console.log(`Updated description for images to ===> ${description}`);
54+
console.log(`Updated name prefix for images to ===> ${namePrefix}`);
55+
}

0 commit comments

Comments
 (0)