A set of tools to automate the migration of NFTs from the old Uniques pallet to the new NFTs pallet.
The migration process consists of multiple steps:
- create a new collection in the nfts pallet using the same account that owns the old collection
- the metadata of both collections should be equal
- take a snapshot of the existing nfts and pre-sign it using the issuer's account
- a generated snapshot file in JSON format needs to be uploaded to IPFS
- store the hash of the generated snapshot file in the collection's attributes
Use scripts below to automate the steps 3-5.
For the steps 1-2 and 5 use the web app.
npm iFill in the .env file with the required data:
UNIQUES_COLLECTON_ID- a collection ID in thepallet-uniquesNFTS_COLLECTON_ID- a collection ID in thepallet-nftsSIGNER_MNEMONIC- a mnemonic phrase of the account that will create offchain signatures. This account needs to have anAdminand anIssuerroles within specifiedNFTS_COLLECTON_ID
You can generate a new one by runningnpm run generate-account.FILEBASE_*- we use the Filebase.com service to store the files on IPFS. A free account on that service will be sufficient.
Generate the offchain signatures for all the items within the UNIQUES_COLLECTON_ID
npm run generate-sigs:allAlternatively, generate the offchain signatures for the unclaimed items only within the UNIQUES_COLLECTON_ID
npm run generate-sigs:unclaimed-onlyUpload the generated file to IPFS
npm run upload-to-ipfsStore file's IPFS hash in collection's attributes. It's recommended to store that information inside the original collection in the uniques pallet.
npm run store-in-uniques-attributesIn a case, the original collection is locked, it's possible to store the same information in the derivative collection.
$ npm run store-in-nfts-attributesNote: you can use the web app to store the IPFS hash in attributes.
After running a script the new json file will be generated and placed into the data folder.
JSON file's structure:
{
"type": "uniques-to-nfts-migration",
"runtimeVersion": 268,
"date": 1690990519099,
"sourceCollection": "0",
"targetCollection": "0",
"signer": "5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL",
"signatures": [
{
"data": "0x00000000020000000000011cbd2d43530a44705ad088af313e18f80b53ef16b36177cd4b77b846f2a5f07c0cf9500000",
"signature": "0x123123"
}
]
}The data field inside the signature object is an encoded version of the PalletNftsPreSignedMint object
which is safe to pass via URL, and it's possible to reconstruct the initial object later in this way:
const preSignedMint = api.createType('PalletNftsPreSignedMint', data);
console.log(preSignedMint.toJSON());npm run generate-account- generates a fresh new accountnpm run inspect-signer- shows the signer's public addressnpm run inspect-generated-json- shows the generated file's name and the IPFS hash
MIT