Mint a NFT With Image and Metadata In 1 Transaction
This section describes how to mint a NFT within a Collection.
You also need to have the address of an XXX contract deployed, the address you are minting to, the path to the image, the name, description, and attributes for the NFT that will be minted. You will need to specify the blockchain network the NFT collection is on, i.e. one of the following supported networks:
- avalanche
- bnbchain
- dogechain
- ethereum
- fantom
- polygon
Assuming you have installed the SDK, you can use the following code in your file (instructions on modifying it follows):
const ido = require('idexo-sdk')
ido.Multi.mintNFTWithImage(apiKey, network, contractAddress, addressToMintTo, image, nftName, nftDescription, attributes)
.then(res => console.log(res.data))
Name | Data Type | Optional | Description |
---|---|---|---|
apiKey | string | required | |
network | string | required | see above for valid networks |
contractAddress | string | required | deployed contract address |
addressToMintTo | string | required | valid EVM address |
image | string | required | can be 1) image file path, 2) URL, or 3) base64 string |
nftName | string | required | |
nftDescription | string | required | |
attributes | json | optional | must be an array. Example: [ { "trait_type": "color", "value": "blue" } ] |
options | object | optional | set metadata storage option (default "arweave"). ex. { metadataStorage: "filecoin" } |
const ido = require('idexo-sdk')
const image = "https://blog.idexo.io/wp-content/uploads/2021/02/cropped-Logo-dark.png"
const attributes =[ { "trait_type": "color", "value": "blue" } ]
const options = { metadataStorage:"filecoin" }
ido.Multi.mintNFTWithImage(
apiKey,
"polygon",
"0x51BB9B9cCdF04af385b8356F41e20140bAdF80a0",
"0x3448a183da142bc6eccfdc690572dfe2d276ddfa",
image, "nftName", "nftDescription", attributes, options
).then(res => console.log(res.data))
// Valid Response
// res.data =>
{
message: 'ido_sdk',
error: null,
data: {
network: 'polygon',
function_name: 'mintWithImage',
args: [
'0x51BB9B9cCdF04af385b8356F41e20140bAdF80a0',
'0x3448a183da142bc6eccfdc690572dfe2d276ddfa',
'nftName',
'nftDescription',
[Array]
],
tx_hash: '0x16e80e4fc91ac2eec909cda9ad124b7590bac44be4ca16ed60e151ba5ae4075b',
tx_status: false,
tx_group: 'collection',
sender: '0x8142409931f554d99013de129cdDc70EA016d62d',
nonce: 12702,
tx_id: '82304090-8cab-11ed-80da-fd24f00cf799',
metadataUri: 'https://arweave.net/xtQEsAyWKEb1Hjov36d4ojlFVkXa9i2MOooF6WI3OS4'
},
code: 200
}
Last modified 4mo ago