Giter Site home page Giter Site logo

js-mcs-sdk's People

Contributors

flyworker avatar rykci avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

js-mcs-sdk's Issues

如何批量上传,批量支付,批量铸造?

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

TypeError: Cannot read properties of undefined (reading 'name')

When I run the js-mcs-sdk test.js:

PS C:\Users\12109\Desktop\mcs-client> node .\test.js
TypeError: Cannot read properties of undefined (reading 'name')
at FormData._getContentDisposition (C:\Users\12109\node_modules\form-data\lib\form_data.js:227:40)
at FormData._multiPartHeader (C:\Users\12109\node_modules\form-data\lib\form_data.js:178:33)
at FormData.append (C:\Users\12109\node_modules\form-data\lib\form_data.js:71:21)
at uploadPromise (C:\Users\12109\node_modules\mcs-client\helper\upload.js:16:8)
at C:\Users\12109\node_modules\mcs-client\helper\upload.js:39:7
at async Promise.all (index 0)
at async mcsUpload (C:\Users\12109\node_modules\mcs-client\helper\upload.js:52:20)
at async mcsClient.upload (C:\Users\12109\node_modules\mcs-client\index.js:54:5)
at async test (C:\Users\12109\Desktop\mcs-client\test.js:21:26)
C:\Users\12109\Desktop\mcs-client\test.js:22
console.log(uploadResponse[0].data.payload_cid)
^

TypeError: Cannot read properties of undefined (reading '0')
at test (C:\Users\12109\Desktop\mcs-client\test.js:22:29)

Here is the test.js code :

require('dotenv').config('C:\\Users\\12109\\.env')
const fs = require('fs')
const { mcsClient } = require('mcs-client')


const client = new mcsClient({
  privateKey: process.env.PRIVATE_KEY,
})

const test = async  () => {
  const fileArray = [
    { fileName: 'jstest', file: fs.createReadStream('./jstest.txt') },
  ]

  const options = {
    delay: 1000, 
    duration: 180, 
    fileType: 0, 
  }

  const uploadResponse = await client.upload(fileArray, options)
  console.log(uploadResponse[0].data.payload_cid)
  console.log(uploadResponse[0].data.ipfs_url)
}

test()

node and npm version:

PS C:\Users\12109\Desktop\mcs-client> node -v
v16.13.1
PS C:\Users\12109\Desktop\mcs-client> npm -v
8.1.2
PS C:\Users\12109\Desktop\mcs-client>

What's wrong with me???

支付成功,但网页显示待支付

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 payloadCid = 'bafykbzacXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
  const tx = await client.makePayment(payloadCid, '0.001')
  console.log(tx.transactionHash)
}
main()

运行后 支付成功并输出tx_hash ,可通过浏览器查到交易详情。
但网页依旧显示未支付,且无法手动支付。

help request: problems paying for storage on poly mumbai testnet

Hi,

I have been having difficulties recently with paying for storage on the testnet even though I believe I have enough funds in wallet.
Below is the error and file details (uploaded to IPFS already). Status appears to be always "pending". Please advise. Thanks.

I have the following fund in test wallet:

0.0968
MATIC

197
USDC

ERROR

/node_modules/web3-core-helpers/lib/errors.js:28
var err = new Error('Returned error: ' + message);
^

Error: Returned error: insufficient funds for gas * price + value
at Object.ErrorResponse (../node_modules/web3-core-helpers/lib/errors.js:28:19)
at ../node_modules/web3-core-requestmanager/lib/index.js:300:36
at ../node_modules/web3-providers-http/lib/index.js:124:13
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
data: null
}

UPLOAD FILE DETAILS

// [
// {
// status: 'success',
// data: {
// source_file_upload_id: 476742,
// payload_cid: 'Qmerw1LjXrcm52y6RoTSmFiZHuHqWKzJ5b8dzpkoofuELf',
// ipfs_url: 'https://calibration-ipfs.filswan.com/ipfs/Qmerw1LjXrcm52y6RoTSmFiZHuHqWKzJ5b8dzpkoofuELf',
// file_size: 19,
// w_cid: '8a1c9f2d-853d-49b2-a87b-299fb21f5d92Qmerw1LjXrcm52y6RoTSmFiZHuHqWKzJ5b8dzpkoofuELf'
// }
// }
// ]

/ [
// {
// source_file_upload_id: 476742,
// car_file_id: 0,
// file_name: 'JnK0N.txt',
// file_size: 19,
// upload_at: 1659664087,
// duration: 525,
// ipfs_url: 'https://calibration-ipfs.filswan.com/ipfs/Qmerw1LjXrcm52y6RoTSmFiZHuHqWKzJ5b8dzpkoofuELf',
// pin_status: 'Pinned',
// payload_cid: '',
// w_cid: '8a1c9f2d-853d-49b2-a87b-299fb21f5d92Qmerw1LjXrcm52y6RoTSmFiZHuHqWKzJ5b8dzpkoofuELf',
// status: 'Pending',
// deal_success: false,
// is_minted: false,
// token_id: null,
// mint_address: null,
// nft_tx_hash: null,
// offline_deal: []
// },

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.