diff --git a/README.md b/README.md index 359349236..0bee7278a 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ const layerConfigurations = [ name: "Eye color", options: { blend: MODE.destinationIn, - opcacity: 0.2, + opacity: 0.2, displayName: "Awesome Eye Color", }, }, diff --git a/constants/network.js b/constants/network.js new file mode 100644 index 000000000..67e78f741 --- /dev/null +++ b/constants/network.js @@ -0,0 +1,10 @@ +"use strict"; + +const NETWORK = { + eth: "eth", + sol: "sol", +}; + +module.exports = { + NETWORK, +}; diff --git a/layers/.DS_Store b/layers/.DS_Store index 1c5c3d85c..5008ddfcf 100644 Binary files a/layers/.DS_Store and b/layers/.DS_Store differ diff --git a/src/config.js b/src/config.js index b139dbc77..a024e40c8 100644 --- a/src/config.js +++ b/src/config.js @@ -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, @@ -83,4 +101,7 @@ module.exports = { extraMetadata, pixelFormat, text, + namePrefix, + network, + solanaMetadata, }; diff --git a/src/main.js b/src/main.js index 403b9f046..f5718f6d2 100644 --- a/src/main.js +++ b/src/main.js @@ -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( @@ -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"); @@ -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 = []; }; @@ -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++ ) { diff --git a/utils/update_info.js b/utils/update_info.js index da3c17c8e..be5854f3c 100644 --- a/utils/update_info.js +++ b/utils/update_info.js @@ -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) @@ -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}`); +}