Releases: AyakaLab/erc1155-info
Releases · AyakaLab/erc1155-info
🔖 v0.1.0 Release
First release of erc1155-info.
Note: This product is still during development, use in production case at your risk
Features:
- 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
Instance Setting
vim config.json
# or
nano config.json
- Replace publicUrl to your domain
- Change port to your free usable port number
Create a new builder
touch src/builders/newBuilder.js
Example Usage for Metadata Builder
// 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
Included it in init.js
const y3dHoe = require('./src/builders/y3dHoe')
/**
* 初始化必要选项,比如 NFT 数据
*/
const init = () => {
y3dHoe.initItems()
}
module.exports = init