Skip to content

Commit

Permalink
Updated Solana Metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
HashLips committed Oct 19, 2021
1 parent ba395a0 commit 9ccc612
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 10 deletions.
10 changes: 10 additions & 0 deletions constants/network.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

const NETWORK = {
eth: "eth",
sol: "sol",
};

module.exports = {
NETWORK,
};
Binary file modified layers/.DS_Store
Binary file not shown.
25 changes: 23 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,28 @@ const path = require("path");
const isLocal = typeof process.pkg === "undefined";
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
const { MODE } = require(path.join(basePath, "constants/blend_mode.js"));
const description =
"This is the description of your NFT project, remember to replace this";
const { NETWORK } = require(path.join(basePath, "constants/network.js"));

const network = NETWORK.eth;

// General metadata for Ethereum
const namePrefix = "Your Collection";
const description = "Remember to replace this description";
const baseUri = "ipfs://NewUriToReplace";

const solanaMetadata = {
symbol: "NOC",
seller_fee_basis_points: 1000, // Define how much % you want from secondary market sales 1000 = 10%
external_url: "https://www.youtube.com/c/hashlipsnft",
creators: [
{
address: "7fXNuer5sbZtaTEPhtJ5g5gNtuyRoKkvxdjEjEnPN4mC",
share: 100,
},
],
};

// If you have selected Solana then the collection starts from 0 automatically
const layerConfigurations = [
{
growEditionSizeTo: 5,
Expand Down Expand Up @@ -83,4 +101,7 @@ module.exports = {
extraMetadata,
pixelFormat,
text,
namePrefix,
network,
solanaMetadata,
};
36 changes: 33 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const path = require("path");
const isLocal = typeof process.pkg === "undefined";
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
const { NETWORK } = require(path.join(basePath, "constants/network.js"));
const fs = require("fs");
const sha1 = require(path.join(basePath, "/node_modules/sha1"));
const { createCanvas, loadImage } = require(path.join(
Expand All @@ -23,6 +24,9 @@ const {
debugLogs,
extraMetadata,
text,
namePrefix,
network,
solanaMetadata,
} = require(path.join(basePath, "/src/config.js"));
const canvas = createCanvas(format.width, format.height);
const ctx = canvas.getContext("2d");
Expand Down Expand Up @@ -118,16 +122,42 @@ const drawBackground = () => {
const addMetadata = (_dna, _edition) => {
let dateTime = Date.now();
let tempMetadata = {
dna: sha1(_dna),
name: `#${_edition}`,
name: `${namePrefix} #${_edition}`,
description: description,
image: `${baseUri}/${_edition}.png`,
dna: sha1(_dna),
edition: _edition,
date: dateTime,
...extraMetadata,
attributes: attributesList,
compiler: "HashLips Art Engine",
};
if (network == NETWORK.sol) {
tempMetadata = {
//Added metadata for solana
name: tempMetadata.name,
symbol: solanaMetadata.symbol,
description: tempMetadata.description,
//Added metadata for solana
seller_fee_basis_points: solanaMetadata.seller_fee_basis_points,
image: `image.png`,
//Added metadata for solana
external_url: solanaMetadata.external_url,
edition: _edition,
...extraMetadata,
attributes: tempMetadata.attributes,
properties: {
files: [
{
uri: "image.png",
type: "image/png",
},
],
category: "image",
creators: solanaMetadata.creators,
},
};
}
metadataList.push(tempMetadata);
attributesList = [];
};
Expand Down Expand Up @@ -254,7 +284,7 @@ const startCreating = async () => {
let failedCount = 0;
let abstractedIndexes = [];
for (
let i = 1;
let i = network == NETWORK.sol ? 0 : 1;
i <= layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo;
i++
) {
Expand Down
35 changes: 30 additions & 5 deletions utils/update_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,32 @@
const path = require("path");
const isLocal = typeof process.pkg === "undefined";
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
const { NETWORK } = require(path.join(basePath, "constants/network.js"));
const fs = require("fs");

console.log(path.join(basePath, "/src/config.js"));
const { baseUri, description } = require(path.join(basePath, "/src/config.js"));
const {
baseUri,
description,
namePrefix,
network,
solanaMetadata,
} = require(path.join(basePath, "/src/config.js"));

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

data.forEach((item) => {
item.description = description;
item.image = `${baseUri}/${item.edition}.png`;
if (network == NETWORK.sol) {
item.name = `${namePrefix} #${item.edition}`;
item.description = description;
item.creators = solanaMetadata.creators;
} else {
item.name = `${namePrefix} #${item.edition}`;
item.description = description;
item.image = `${baseUri}/${item.edition}.png`;
}
fs.writeFileSync(
`${basePath}/build/json/${item.edition}.json`,
JSON.stringify(item, null, 2)
Expand All @@ -26,5 +40,16 @@ fs.writeFileSync(
JSON.stringify(data, null, 2)
);

console.log(`Updated baseUri for images to ===> ${baseUri}`);
console.log(`Updated description for images to ===> ${description}`);
if (network == NETWORK.sol) {
console.log(`Updated description for images to ===> ${description}`);
console.log(`Updated name prefix for images to ===> ${namePrefix}`);
console.log(
`Updated creators for images to ===> ${JSON.stringify(
solanaMetadata.creators
)}`
);
} else {
console.log(`Updated baseUri for images to ===> ${baseUri}`);
console.log(`Updated description for images to ===> ${description}`);
console.log(`Updated name prefix for images to ===> ${namePrefix}`);
}

1 comment on commit 9ccc612

@senja2322
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saya tidak bisa npm instal kenapa ya

Please sign in to comment.