Last active
December 20, 2023 11:31
-
-
Save fukaoi/47c5c41418b70e868c1b0ed69332efd3 to your computer and use it in GitHub Desktop.
Mint a cNFT using the solana suite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Airdrop } from '@solana-suite/airdrop'; | |
import { | |
Account, | |
CompressedNft, | |
Explorer, | |
sleep, | |
} from '@solana-suite/compressed-nft'; | |
(async () => { | |
const owner = Account.Keypair.create(); | |
await Airdrop.request(owner.pubkey); | |
await sleep(2); // wait time | |
// CREATE SPACE | |
const spaceInst = await CompressedNft.createSpace(owner.secret, 8); | |
const space = spaceInst.unwrap().data; | |
// CREATE COLLECTION NFT | |
const collectionInst = await CompressedNft.mintCollection(owner.secret, { | |
uri: 'https://bafybeih4yaqorp7tev3vin4zvgmzxt2kesk2gzyrnx24hhvahjdcjghsgu.ipfs.dweb.link/', | |
name: 'Animals Collection', | |
symbol: 'ANIC', | |
}); | |
const mintCollection = collectionInst.unwrap().data; | |
await [spaceInst, collectionInst].submit(); | |
// CREATE cNFT | |
const mintInst = await CompressedNft.mint( | |
owner.secret, | |
{ | |
uri: 'https://bafkreicfunctsdeqjxomdlvikp32h7u5ux473c3cvhkmceeb2kaczxpm4e.ipfs.dweb.link/', | |
name: 'Lion', | |
symbol: 'ANIC-LION', | |
}, | |
space, | |
mintCollection, | |
); | |
(await mintInst.submit()).match( | |
async (value) => { | |
console.log('# sig: ', value.toExplorerUrl(Explorer.Xray)); | |
}, | |
(error) => console.error(error), | |
); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment