The Backbone Server serves Metadatas for ERC1155 based NFT Cards
We aim to build a general ERC1155 metadata server that you can quickly deploy into all different project and aspect
- Metadata Builder API included, save time on building metadata
- Development compatible for all purpose with nodemon hot reload
- Koa2 based minified application to scale down any large application building time
- Opening option for user to customize the usage of this project
- No other database or addtional instance required, download and go
- Fully supported Logger included powered by log4js
git clone https://github.com/AyakaLab/erc1155-info.git
yarn
# or
npm install
yarn conf
# or
npm run conf
vim config.json
# or
nano config.json
- Replace publicUrl to your domain
- Change port to your free usable port number
touch src/builders/newBuilder.js
// Dependencies
const fs = require('fs')
const path = require('path')
const Log = require('../util/log')
const MetadataBuilder = require('../generator/metadataBuilder')
const config = require('../../config.json')
const dataArray = [
{
id: 1,
name: "Level1",
value: 100,
level: 1,
color: '#333333',
nameZhCN: '一级物品',
ability: 'speedup mining',
image: config.publicUrl + '/image/set1/Item1.png'
},
{
id: 2,
name: "Level2",
value: 200,
level: 2,
color: '#333333',
nameZhCN: '二级物品',
ability: 'speedup mining',
image: config.publicUrl + '/image/set1/Item2.png'
}
]
const HoeBuilder = {
initItems() {
const metdadataDir = path.resolve('./assets/metadata')
for (let i = 0; i < hoeArray.length; i++) {
const item = hoeArray[i]
if (fs.existsSync(path.join(metdadataDir, item.id + '.json'))) return
let attr = []
attr.push(MetadataBuilder.attributesBuilder('Level', item.level))
attr.push(MetadataBuilder.attributesBuilder('Type', 'default'))
attr.push(MetadataBuilder.attributesBuilder('Ability', item.ability))
attr.push(MetadataBuilder.attributesBuilder('Auction Base', item.value))
attr.push(MetadataBuilder.attributesBuilder('Main Color', item.color))
attr.push(MetadataBuilder.attributesBuilder('Name_CHN', item.nameZhCN))
let body = MetadataBuilder.builder(
config.publicUrl + '/' + item.id,
item.image,
item.name,
'',
attr
)
const location = MetadataBuilder.toJsonFile('', item.id, body)
Log.trace(`Built JSON metadata for ${item.name} (id: ${item.id}) to ${location}`)
}
}
}
module.exports = HoeBuilder
const y3dHoe = require('./src/builders/y3dHoe')
/**
* 初始化必要选项,比如 NFT 数据
*/
const init = () => {
y3dHoe.initItems()
}
module.exports = init
yarn start