Upload to IPFS

Create another file called ipfs.js with the following code:

var npmMintNft = require('nifty-toolkit');
const fs = require('fs');
const FormData = require('form-data');

var ipfs = new npmMintNft.Ipfs({
    pinKey: 'fill_in_your_pinata_key',
    pinSecret: 'fill_in_your_pinata_secret',
});

ipfs.pinJSONToIPFS({
    name: '',
    images: ''
}).then(res => {
    console.log(res);
})

var fd = new FormData();
fd.append("file", fs.createReadStream('png'), Date.now() + ".jpg");

ipfs.pinFileToIPFS(fd).then(res => {
    console.log(res);
})

Make sure to fill in your Pinata key and secret.

Run the file:

node ipfs.js

Last updated