如何批量上传,批量支付,批量铸造?
Closed this issue · 0 comments
BBQFIL commented
require('dotenv').config('./.env')
const fs = require('fs').promises
const { mcsClient } = require('mcs-client')
const client = new mcsClient({
privateKey: process.env.PRIVATE_KEY,
rpcUrl: process.env.RPC_URL,
})
async function main() {
const fileArray = [
{ fileName: 'AAAA', file: await fs.readFile('./AAAA') },
{ fileName: 'BBBB', file: await fs.readFile('./BBBB') },
{ fileName: 'CCCC', file: await fs.readFile('./CCCC') },
]
const options = {
delay: 1,
duration: 525,
fileType: 0,
}
const uploadResponses = await client.upload(fileArray, options)
console.log(uploadResponses)
const payloadCid = uploadResponses[0].data.payload_cid
const tx = await client.makePayment(payloadCid, '0.002')
console.log(tx.transactionHash)
const nft = {
name: 'NFT',
description: 'NFT',
image: uploadResponses[0].data.ipfs_url,
tx_hash: '0x...',
}
const mintTx = await client.mintAsset(payloadCid, nft)
console.log(mintTx)
}
main()
这样写只能批量上传,但是只有第一个文件被支付和铸造。
应该怎么改? @rykci