For the complete documentation index, see llms.txt. This page is also available as Markdown.

铸造NFT

Mint NFT to MCS Opensea Collection

mintAsset(sourceFileUploadId, nftObject)

The following code example mints an uploaded file as a NFT viewable on Opensea. Create an NFT object and provide the payload_cid of the file. The NFT object follows the Opensea metadata standards.

require('dotenv').config()
const { mcsSDK } = require('js-mcs-sdk')

// set up js-mcs-sdk
const mcs = new mcsSDK({
  privateKey: process.env.PRIVATE_KEY,
  rpcUrl: process.env.RPC_URL,
})

async function main() {
  // ENTER PARAMETERS
  const SOURCE_FILE_UPLOAD_ID = 0
  const IPFS_URL = ''
  const NFT_NAME = ''

  const NFT_DESCRIPTION = '' // optional

  const nft = {
    name: NFT_NAME, // the name of your NFT
    image: IPFS_URL, // asset URI, images will render on Opensea
    external_url: IPFS_URL, // Opensea will provide a link to view the source
    description: NFT_DESCRIPTION, // description of your NFT
    attributes: [], // NFT attributes displayed on Opensea
  }

  const mintTx = await mcs.mintAsset(SOURCE_FILE_UPLOAD_ID, nft)
  console.log(mintTx)
}

main()

The NFT smart contract can be found in the GitHub repository below:

Parameters

  • sourceFileUploadId: upload Id of the file

  • nftObject: object following Opensea Metadata Standards

    • name: name of your NFT (required)

    • image: IPFS URL of your file (required)

    • description: description of your NFT

    • external_url: viewable link on Opensea UI

    • attributes: array of attribute objects you wish to show on Opensea

Return

Returns the response from the /mint/info API

Last updated