-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-create-pack-from-bundle.js
39 lines (32 loc) · 1.13 KB
/
4-create-pack-from-bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { readFileSync } from 'fs';
import { sdk } from './helpers.js';
async function main() {
const bundleModuleAddress = '0x51207eB947f6215ce6db5CEf24083c9A5d281f7b';
const bundleModule = sdk.getBundleModule(bundleModuleAddress);
const packModuleAddress = '0x5e680F9b540e862893f1061dfd0eA2081122aB05';
const packModule = sdk.getPackModule(packModuleAddress);
console.log('Getting all NFTs from bundle...');
const nftsInBundle = await bundleModule.getAll();
console.log('NFTs in bundle:');
console.log(nftsInBundle);
console.log('Creating a pack containing the NFTS from bundle...');
const created = await packModule.create({
assetContract: bundleModuleAddress,
metadata: {
name: 'Mother Fucking Dogs Pack!',
image: readFileSync('./assets/Dogs.jpg'),
},
assets: nftsInBundle.map(nft => ({
tokenId: nft.metadata.id,
amount: nft.supply,
})),
});
console.log('Pack created!');
console.log(created);
}
try {
await main();
} catch (error) {
console.error("Error minting the NFTs", error);
process.exit(1);
}