没有找到单独获取铸造所需ipfs_url的方法
Closed this issue · 4 comments
如果文件上传完毕后没有进行铸造, 那么以后铸造时该如何获取文件的ipfs_url?
Usually, the user will find the ipfs_url
returned from client.upload()
to find the ipfs_url
later, it is found by client.getFileDetails(payload_cid, deal_id)
to find the deal_id
... the user can search the deal list client.listUploads(wallet_address, payload_cid)
(can also use client.publicKey to get wallet_address
ex.
async function main() {
PAYLOAD_CID = 'bafk2bzaceddm5zocmawl4jrstyi3cfzdmqok7mhaac44gvv7w5oxtzyp2ztse'
WALLET_ADDRESS = '0xb1DAB7708d6E3dE3006861b68dE3c1a4055DbAaB'
// find deal_id
const uploadInfo = await client.listUploads(PAYLOAD_CID, PAYLOAD_CID)
const dealId = uploadInfo.data.deal_id
const fileDetails = await client.getFileDetails(PAYLOAD_CID, dealId)
console.log(fileDetails.data.deal.ipfs_url)
// https://calibration-ipfs.filswan.com/ipfs/QmP5haQgHZ2sbWTGmArCq6qy1y5ifBWqkvHhBfS6A19i46
}
`c
onst nft = {
name: 'File 1', // the name of your NFT
description: 'This is the first file', // the description of your NFT
image: uploadResponses[0].data.ipfs_url, // asset URI, images will render on Opensea
tx_hash: '0x...', // payment tx_hash, will be inserted automatically
}
const mintTx = await client.mintAsset(payloadCid, nft)
console.log(mintTx)
`
如果我有个文件只上传没有铸造,后来我再想铸造改如何获取ipfs_url
Adding on to my example code:
async function main() {
PAYLOAD_CID = 'bafkqac33ejqseorcmfzwiit5'
WALLET_ADDRESS = '0xb1DAB7708d6E3dE3006861b68dE3c1a4055DbAaB'
// find deal_id
const uploadInfo = await client.listUploads(PAYLOAD_CID, PAYLOAD_CID)
const dealId = uploadInfo.data.deal_id
const fileDetails = await client.getFileDetails(PAYLOAD_CID, dealId)
console.log(fileDetails.data.deal.ipfs_url)
const nft = {
name: 'My NFT Name',
image: fileDetails.data.deal.ipfs_url,
}
const mintTx = await client.mintAsset(PAYLOAD_CID, nft)
console.log(mintTx)
}
谢谢~我试下