neozipkit 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +400 -0
  2. package/contracts/Lock.sol +34 -0
  3. package/contracts/bytecode.txt +1 -0
  4. package/contracts/compile-contract.js +168 -0
  5. package/contracts/deploy/deploy-both-contracts.js +286 -0
  6. package/contracts/deploy/deploy-enhanced-contract.js +197 -0
  7. package/contracts/deploy/deploy-private-contract.js +190 -0
  8. package/contracts/deploy/deploy-public-clean.js +1063 -0
  9. package/contracts/deploy/deploy-public-contract.js +1107 -0
  10. package/contracts/deployment.config.example.js +25 -0
  11. package/contracts/remix-compile.js +222 -0
  12. package/contracts/setup-deployment.js +51 -0
  13. package/contracts/src/NZIP-NFT-Private.sol +350 -0
  14. package/contracts/src/NZIP-NFT.sol +265 -0
  15. package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +260 -0
  16. package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +289 -0
  17. package/dist/browser/CertificateGeneratorBrowser.d.ts +75 -0
  18. package/dist/browser/CertificateGeneratorBrowser.js +433 -0
  19. package/dist/browser/TokenVerifierBrowser.d.ts +76 -0
  20. package/dist/browser/TokenVerifierBrowser.js +299 -0
  21. package/dist/browser/ZipKitBrowser.d.ts +18 -0
  22. package/dist/browser/ZipKitBrowser.js +250 -0
  23. package/dist/browser/ZipKitStampBrowser.d.ts +2 -0
  24. package/dist/browser/ZipKitStampBrowser.js +12 -0
  25. package/dist/browser-index.d.ts +21 -0
  26. package/dist/browser-index.js +58 -0
  27. package/dist/browser.d.ts +21 -0
  28. package/dist/browser.js +58 -0
  29. package/dist/index.d.ts +29 -0
  30. package/dist/index.js +76 -0
  31. package/dist/server/blockchain/CertificateToken.d.ts +48 -0
  32. package/dist/server/blockchain/CertificateToken.js +386 -0
  33. package/dist/server/blockchain/NFTMinter.d.ts +41 -0
  34. package/dist/server/blockchain/NFTMinter.js +323 -0
  35. package/dist/server/blockchain/TokenQuerier.d.ts +31 -0
  36. package/dist/server/blockchain/TokenQuerier.js +259 -0
  37. package/dist/server/blockchain/TokenVerifier.d.ts +20 -0
  38. package/dist/server/blockchain/TokenVerifier.js +395 -0
  39. package/dist/server/blockchain/WalletAnalyzer.d.ts +81 -0
  40. package/dist/server/blockchain/WalletAnalyzer.js +356 -0
  41. package/dist/server/blockchain/WalletFormatter.d.ts +39 -0
  42. package/dist/server/blockchain/WalletFormatter.js +196 -0
  43. package/dist/server/blockchain/WalletManager.d.ts +46 -0
  44. package/dist/server/blockchain/WalletManager.js +294 -0
  45. package/dist/server/blockchain/ZipMetadata.d.ts +27 -0
  46. package/dist/server/blockchain/ZipMetadata.js +131 -0
  47. package/dist/server/blockchain/ZipTokenProcessor.d.ts +44 -0
  48. package/dist/server/blockchain/ZipTokenProcessor.js +204 -0
  49. package/dist/server/blockchain/constants.d.ts +102 -0
  50. package/dist/server/blockchain/constants.js +968 -0
  51. package/dist/server/blockchain/index.d.ts +9 -0
  52. package/dist/server/blockchain/index.js +44 -0
  53. package/dist/server/blockchain/test-certificate.d.ts +8 -0
  54. package/dist/server/blockchain/test-certificate.js +100 -0
  55. package/dist/server/blockchain/types.d.ts +69 -0
  56. package/dist/server/blockchain/types.js +51 -0
  57. package/dist/server/platform/server/ZipKitServer.d.ts +105 -0
  58. package/dist/server/platform/server/ZipKitServer.js +437 -0
  59. package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +91 -0
  60. package/dist/server/platform/servercomponents/ZipKitOTS.js +271 -0
  61. package/dist/shared/ZipEntry.d.ts +131 -0
  62. package/dist/shared/ZipEntry.js +686 -0
  63. package/dist/shared/ZipKit.d.ts +249 -0
  64. package/dist/shared/ZipKit.js +789 -0
  65. package/dist/shared/components/CertificateOTS.d.ts +15 -0
  66. package/dist/shared/components/CertificateOTS.js +116 -0
  67. package/dist/shared/components/FileSys.d.ts +2 -0
  68. package/dist/shared/components/FileSys.js +113 -0
  69. package/dist/shared/components/HashAccumulator.d.ts +55 -0
  70. package/dist/shared/components/HashAccumulator.js +100 -0
  71. package/dist/shared/components/Support.d.ts +63 -0
  72. package/dist/shared/components/Support.js +70 -0
  73. package/dist/shared/components/Util.d.ts +21 -0
  74. package/dist/shared/components/Util.js +115 -0
  75. package/dist/shared/components/ZipCrypto.d.ts +3 -0
  76. package/dist/shared/components/ZipCrypto.js +78 -0
  77. package/dist/shared/components/merkleTree.d.ts +66 -0
  78. package/dist/shared/components/merkleTree.js +136 -0
  79. package/dist/shared/constants/Errors.d.ts +53 -0
  80. package/dist/shared/constants/Errors.js +69 -0
  81. package/dist/shared/constants/Headers.d.ts +167 -0
  82. package/dist/shared/constants/Headers.js +191 -0
  83. package/dist/shared/types/index.d.ts +21 -0
  84. package/dist/shared/types/index.js +3 -0
  85. package/dist/shared/types.d.ts +33 -0
  86. package/dist/shared/types.js +8 -0
  87. package/dist/shared/version.d.ts +4 -0
  88. package/dist/shared/version.js +7 -0
  89. package/dist/types/index.d.ts +21 -0
  90. package/dist/types/index.js +3 -0
  91. package/examples/unzip-token.ts +488 -0
  92. package/examples/zip-token.ts +604 -0
  93. package/package.json +117 -0
  94. package/src/browser/CertificateGeneratorBrowser.ts +498 -0
  95. package/src/browser/TokenVerifierBrowser.ts +344 -0
  96. package/src/browser/ZipKitBrowser.ts +242 -0
  97. package/src/browser/ZipKitStampBrowser.ts +9 -0
  98. package/src/browser-index.ts +36 -0
  99. package/src/index.ts +48 -0
  100. package/src/server/blockchain/CertificateToken.ts +444 -0
  101. package/src/server/blockchain/NFTMinter.ts +357 -0
  102. package/src/server/blockchain/TokenQuerier.ts +287 -0
  103. package/src/server/blockchain/TokenVerifier.ts +453 -0
  104. package/src/server/blockchain/WalletAnalyzer.ts +397 -0
  105. package/src/server/blockchain/WalletFormatter.ts +206 -0
  106. package/src/server/blockchain/WalletManager.ts +294 -0
  107. package/src/server/blockchain/ZipMetadata.ts +117 -0
  108. package/src/server/blockchain/ZipTokenProcessor.ts +234 -0
  109. package/src/server/blockchain/constants.ts +969 -0
  110. package/src/server/blockchain/index.ts +42 -0
  111. package/src/server/blockchain/test-certificate.ts +137 -0
  112. package/src/server/blockchain/types.ts +134 -0
  113. package/src/server/platform/server/ZipKitServer.ts +459 -0
  114. package/src/server/platform/servercomponents/ZipKitOTS.ts +313 -0
  115. package/src/server/platform/servercomponents/opentimestamps.d.ts +23 -0
  116. package/src/shared/ZipEntry.ts +767 -0
  117. package/src/shared/ZipKit.ts +899 -0
  118. package/src/shared/components/CertificateOTS.ts +132 -0
  119. package/src/shared/components/FileSys.ts +87 -0
  120. package/src/shared/components/HashAccumulator.ts +113 -0
  121. package/src/shared/components/Support.ts +77 -0
  122. package/src/shared/components/Util.ts +113 -0
  123. package/src/shared/components/ZipCrypto.ts +91 -0
  124. package/src/shared/components/merkleTree.ts +162 -0
  125. package/src/shared/constants/Errors.ts +82 -0
  126. package/src/shared/constants/Headers.ts +203 -0
  127. package/src/shared/types/index.ts +25 -0
  128. package/src/shared/types/modules.d.ts +22 -0
  129. package/src/shared/types/opentimestamps.d.ts +23 -0
  130. package/src/shared/types.d.ts +8 -0
  131. package/src/shared/types.ts +43 -0
  132. package/src/shared/version.ts +4 -0
  133. package/src/types/index.ts +25 -0
  134. package/src/types/modules.d.ts +22 -0
  135. package/src/types/opentimestamps.d.ts +23 -0
@@ -0,0 +1,1063 @@
1
+ const { ethers } = require('ethers');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ /**
6
+ * Clean NZIP NFT Public Contract Deployment Script
7
+ * Reads bytecode from external file to avoid issues with large strings
8
+ */
9
+
10
+ // Configuration - Load from environment variables or config file
11
+ function loadConfig() {
12
+ let config = {};
13
+
14
+ try {
15
+ config = require('../deployment.config.js');
16
+ console.log('šŸ“ Loaded configuration from deployment.config.js');
17
+ } catch (err) {
18
+ console.log('šŸ“ No deployment.config.js found, using environment variables');
19
+ }
20
+
21
+ const CHAIN_ID = process.env.CHAIN_ID ? parseInt(process.env.CHAIN_ID) : (config.CHAIN_ID || 84532);
22
+ const PRIVATE_KEY = process.env.PRIVATE_KEY || config.PRIVATE_KEY;
23
+
24
+ return { CHAIN_ID, PRIVATE_KEY, EXISTING_CONTRACT: config.EXISTING_CONTRACT };
25
+ }
26
+
27
+ const { CHAIN_ID, PRIVATE_KEY, EXISTING_CONTRACT } = loadConfig();
28
+
29
+ // Network configurations
30
+ const NETWORK_CONFIG = {
31
+ 84532: {
32
+ name: 'Base Sepolia',
33
+ rpcUrl: 'https://sepolia.base.org',
34
+ explorer: 'https://sepolia.basescan.org'
35
+ },
36
+ 8453: {
37
+ name: 'Base Mainnet',
38
+ rpcUrl: 'https://mainnet.base.org',
39
+ explorer: 'https://basescan.org'
40
+ }
41
+ };
42
+
43
+ // Load bytecode and ABI from files
44
+ function loadContractData() {
45
+ const bytecodePath = path.join(__dirname, '../bytecode.txt');
46
+
47
+ if (!fs.existsSync(bytecodePath)) {
48
+ throw new Error('āŒ bytecode.txt file not found. Please create it and paste your compiled bytecode.');
49
+ }
50
+
51
+ const bytecode = fs.readFileSync(bytecodePath, 'utf8').trim();
52
+
53
+ if (!bytecode || bytecode === 'PASTE_YOUR_COMPILED_BYTECODE_HERE') {
54
+ throw new Error('āŒ Please paste your compiled bytecode into contracts/bytecode.txt');
55
+ }
56
+
57
+ const abi = [
58
+ {
59
+ "inputs": [],
60
+ "stateMutability": "nonpayable",
61
+ "type": "constructor"
62
+ },
63
+ {
64
+ "inputs": [
65
+ {
66
+ "internalType": "address",
67
+ "name": "sender",
68
+ "type": "address"
69
+ },
70
+ {
71
+ "internalType": "uint256",
72
+ "name": "tokenId",
73
+ "type": "uint256"
74
+ },
75
+ {
76
+ "internalType": "address",
77
+ "name": "owner",
78
+ "type": "address"
79
+ }
80
+ ],
81
+ "name": "ERC721IncorrectOwner",
82
+ "type": "error"
83
+ },
84
+ {
85
+ "inputs": [
86
+ {
87
+ "internalType": "address",
88
+ "name": "operator",
89
+ "type": "address"
90
+ },
91
+ {
92
+ "internalType": "uint256",
93
+ "name": "tokenId",
94
+ "type": "uint256"
95
+ }
96
+ ],
97
+ "name": "ERC721InsufficientApproval",
98
+ "type": "error"
99
+ },
100
+ {
101
+ "inputs": [
102
+ {
103
+ "internalType": "address",
104
+ "name": "approver",
105
+ "type": "address"
106
+ }
107
+ ],
108
+ "name": "ERC721InvalidApprover",
109
+ "type": "error"
110
+ },
111
+ {
112
+ "inputs": [
113
+ {
114
+ "internalType": "address",
115
+ "name": "operator",
116
+ "type": "address"
117
+ }
118
+ ],
119
+ "name": "ERC721InvalidOperator",
120
+ "type": "error"
121
+ },
122
+ {
123
+ "inputs": [
124
+ {
125
+ "internalType": "address",
126
+ "name": "owner",
127
+ "type": "address"
128
+ }
129
+ ],
130
+ "name": "ERC721InvalidOwner",
131
+ "type": "error"
132
+ },
133
+ {
134
+ "inputs": [
135
+ {
136
+ "internalType": "address",
137
+ "name": "receiver",
138
+ "type": "address"
139
+ }
140
+ ],
141
+ "name": "ERC721InvalidReceiver",
142
+ "type": "error"
143
+ },
144
+ {
145
+ "inputs": [
146
+ {
147
+ "internalType": "address",
148
+ "name": "sender",
149
+ "type": "address"
150
+ }
151
+ ],
152
+ "name": "ERC721InvalidSender",
153
+ "type": "error"
154
+ },
155
+ {
156
+ "inputs": [
157
+ {
158
+ "internalType": "uint256",
159
+ "name": "tokenId",
160
+ "type": "uint256"
161
+ }
162
+ ],
163
+ "name": "ERC721NonexistentToken",
164
+ "type": "error"
165
+ },
166
+ {
167
+ "inputs": [
168
+ {
169
+ "internalType": "address",
170
+ "name": "owner",
171
+ "type": "address"
172
+ }
173
+ ],
174
+ "name": "OwnableInvalidOwner",
175
+ "type": "error"
176
+ },
177
+ {
178
+ "inputs": [
179
+ {
180
+ "internalType": "address",
181
+ "name": "account",
182
+ "type": "address"
183
+ }
184
+ ],
185
+ "name": "OwnableUnauthorizedAccount",
186
+ "type": "error"
187
+ },
188
+ {
189
+ "anonymous": false,
190
+ "inputs": [
191
+ {
192
+ "indexed": true,
193
+ "internalType": "address",
194
+ "name": "owner",
195
+ "type": "address"
196
+ },
197
+ {
198
+ "indexed": true,
199
+ "internalType": "address",
200
+ "name": "approved",
201
+ "type": "address"
202
+ },
203
+ {
204
+ "indexed": true,
205
+ "internalType": "uint256",
206
+ "name": "tokenId",
207
+ "type": "uint256"
208
+ }
209
+ ],
210
+ "name": "Approval",
211
+ "type": "event"
212
+ },
213
+ {
214
+ "anonymous": false,
215
+ "inputs": [
216
+ {
217
+ "indexed": true,
218
+ "internalType": "address",
219
+ "name": "owner",
220
+ "type": "address"
221
+ },
222
+ {
223
+ "indexed": true,
224
+ "internalType": "address",
225
+ "name": "operator",
226
+ "type": "address"
227
+ },
228
+ {
229
+ "indexed": false,
230
+ "internalType": "bool",
231
+ "name": "approved",
232
+ "type": "bool"
233
+ }
234
+ ],
235
+ "name": "ApprovalForAll",
236
+ "type": "event"
237
+ },
238
+ {
239
+ "anonymous": false,
240
+ "inputs": [
241
+ {
242
+ "indexed": false,
243
+ "internalType": "uint256",
244
+ "name": "_fromTokenId",
245
+ "type": "uint256"
246
+ },
247
+ {
248
+ "indexed": false,
249
+ "internalType": "uint256",
250
+ "name": "_toTokenId",
251
+ "type": "uint256"
252
+ }
253
+ ],
254
+ "name": "BatchMetadataUpdate",
255
+ "type": "event"
256
+ },
257
+ {
258
+ "anonymous": false,
259
+ "inputs": [
260
+ {
261
+ "indexed": false,
262
+ "internalType": "uint256",
263
+ "name": "_tokenId",
264
+ "type": "uint256"
265
+ }
266
+ ],
267
+ "name": "MetadataUpdate",
268
+ "type": "event"
269
+ },
270
+ {
271
+ "anonymous": false,
272
+ "inputs": [
273
+ {
274
+ "indexed": true,
275
+ "internalType": "address",
276
+ "name": "previousOwner",
277
+ "type": "address"
278
+ },
279
+ {
280
+ "indexed": true,
281
+ "internalType": "address",
282
+ "name": "newOwner",
283
+ "type": "address"
284
+ }
285
+ ],
286
+ "name": "OwnershipTransferred",
287
+ "type": "event"
288
+ },
289
+ {
290
+ "anonymous": false,
291
+ "inputs": [
292
+ {
293
+ "indexed": true,
294
+ "internalType": "address",
295
+ "name": "from",
296
+ "type": "address"
297
+ },
298
+ {
299
+ "indexed": true,
300
+ "internalType": "address",
301
+ "name": "to",
302
+ "type": "address"
303
+ },
304
+ {
305
+ "indexed": true,
306
+ "internalType": "uint256",
307
+ "name": "tokenId",
308
+ "type": "uint256"
309
+ }
310
+ ],
311
+ "name": "Transfer",
312
+ "type": "event"
313
+ },
314
+ {
315
+ "anonymous": false,
316
+ "inputs": [
317
+ {
318
+ "indexed": true,
319
+ "internalType": "uint256",
320
+ "name": "tokenId",
321
+ "type": "uint256"
322
+ },
323
+ {
324
+ "indexed": true,
325
+ "internalType": "address",
326
+ "name": "creator",
327
+ "type": "address"
328
+ },
329
+ {
330
+ "indexed": false,
331
+ "internalType": "string",
332
+ "name": "fileName",
333
+ "type": "string"
334
+ },
335
+ {
336
+ "indexed": false,
337
+ "internalType": "string",
338
+ "name": "merkleRootHash",
339
+ "type": "string"
340
+ },
341
+ {
342
+ "indexed": false,
343
+ "internalType": "uint256",
344
+ "name": "creationTimestamp",
345
+ "type": "uint256"
346
+ },
347
+ {
348
+ "indexed": false,
349
+ "internalType": "string",
350
+ "name": "ipfsHash",
351
+ "type": "string"
352
+ },
353
+ {
354
+ "indexed": false,
355
+ "internalType": "uint256",
356
+ "name": "tokenizationTime",
357
+ "type": "uint256"
358
+ },
359
+ {
360
+ "indexed": false,
361
+ "internalType": "uint256",
362
+ "name": "blockNumber",
363
+ "type": "uint256"
364
+ }
365
+ ],
366
+ "name": "ZipFileTokenized",
367
+ "type": "event"
368
+ },
369
+ {
370
+ "inputs": [
371
+ {
372
+ "internalType": "address",
373
+ "name": "to",
374
+ "type": "address"
375
+ },
376
+ {
377
+ "internalType": "uint256",
378
+ "name": "tokenId",
379
+ "type": "uint256"
380
+ }
381
+ ],
382
+ "name": "approve",
383
+ "outputs": [],
384
+ "stateMutability": "nonpayable",
385
+ "type": "function"
386
+ },
387
+ {
388
+ "inputs": [
389
+ {
390
+ "internalType": "address",
391
+ "name": "owner",
392
+ "type": "address"
393
+ }
394
+ ],
395
+ "name": "balanceOf",
396
+ "outputs": [
397
+ {
398
+ "internalType": "uint256",
399
+ "name": "",
400
+ "type": "uint256"
401
+ }
402
+ ],
403
+ "stateMutability": "view",
404
+ "type": "function"
405
+ },
406
+ {
407
+ "inputs": [
408
+ {
409
+ "internalType": "bytes32",
410
+ "name": "",
411
+ "type": "bytes32"
412
+ }
413
+ ],
414
+ "name": "compositeKeyToTokenId",
415
+ "outputs": [
416
+ {
417
+ "internalType": "uint256",
418
+ "name": "",
419
+ "type": "uint256"
420
+ }
421
+ ],
422
+ "stateMutability": "view",
423
+ "type": "function"
424
+ },
425
+ {
426
+ "inputs": [
427
+ {
428
+ "internalType": "string",
429
+ "name": "merkleRootHash",
430
+ "type": "string"
431
+ },
432
+ {
433
+ "internalType": "uint256",
434
+ "name": "creationTimestamp",
435
+ "type": "uint256"
436
+ }
437
+ ],
438
+ "name": "generateCompositeKey",
439
+ "outputs": [
440
+ {
441
+ "internalType": "bytes32",
442
+ "name": "",
443
+ "type": "bytes32"
444
+ }
445
+ ],
446
+ "stateMutability": "pure",
447
+ "type": "function"
448
+ },
449
+ {
450
+ "inputs": [
451
+ {
452
+ "internalType": "uint256",
453
+ "name": "tokenId",
454
+ "type": "uint256"
455
+ }
456
+ ],
457
+ "name": "getApproved",
458
+ "outputs": [
459
+ {
460
+ "internalType": "address",
461
+ "name": "",
462
+ "type": "address"
463
+ }
464
+ ],
465
+ "stateMutability": "view",
466
+ "type": "function"
467
+ },
468
+ {
469
+ "inputs": [
470
+ {
471
+ "internalType": "uint256",
472
+ "name": "tokenId",
473
+ "type": "uint256"
474
+ }
475
+ ],
476
+ "name": "getBlockchainMetadata",
477
+ "outputs": [
478
+ {
479
+ "internalType": "uint256",
480
+ "name": "blockNumber",
481
+ "type": "uint256"
482
+ },
483
+ {
484
+ "internalType": "uint256",
485
+ "name": "tokenizationTime",
486
+ "type": "uint256"
487
+ }
488
+ ],
489
+ "stateMutability": "view",
490
+ "type": "function"
491
+ },
492
+ {
493
+ "inputs": [
494
+ {
495
+ "internalType": "string",
496
+ "name": "merkleRoot",
497
+ "type": "string"
498
+ }
499
+ ],
500
+ "name": "getTokensByMerkleRoot",
501
+ "outputs": [
502
+ {
503
+ "internalType": "uint256[]",
504
+ "name": "",
505
+ "type": "uint256[]"
506
+ }
507
+ ],
508
+ "stateMutability": "view",
509
+ "type": "function"
510
+ },
511
+ {
512
+ "inputs": [],
513
+ "name": "getVersion",
514
+ "outputs": [
515
+ {
516
+ "internalType": "string",
517
+ "name": "",
518
+ "type": "string"
519
+ }
520
+ ],
521
+ "stateMutability": "pure",
522
+ "type": "function"
523
+ },
524
+ {
525
+ "inputs": [
526
+ {
527
+ "internalType": "uint256",
528
+ "name": "tokenId",
529
+ "type": "uint256"
530
+ }
531
+ ],
532
+ "name": "getZipFileInfo",
533
+ "outputs": [
534
+ {
535
+ "components": [
536
+ {
537
+ "internalType": "string",
538
+ "name": "fileName",
539
+ "type": "string"
540
+ },
541
+ {
542
+ "internalType": "string",
543
+ "name": "merkleRootHash",
544
+ "type": "string"
545
+ },
546
+ {
547
+ "internalType": "string",
548
+ "name": "ipfsHash",
549
+ "type": "string"
550
+ },
551
+ {
552
+ "internalType": "address",
553
+ "name": "creator",
554
+ "type": "address"
555
+ },
556
+ {
557
+ "internalType": "uint256",
558
+ "name": "creationTimestamp",
559
+ "type": "uint256"
560
+ },
561
+ {
562
+ "internalType": "uint256",
563
+ "name": "tokenizationTime",
564
+ "type": "uint256"
565
+ },
566
+ {
567
+ "internalType": "uint256",
568
+ "name": "blockNumber",
569
+ "type": "uint256"
570
+ }
571
+ ],
572
+ "internalType": "struct ZipFileNFT.ZipFileInfo",
573
+ "name": "",
574
+ "type": "tuple"
575
+ }
576
+ ],
577
+ "stateMutability": "view",
578
+ "type": "function"
579
+ },
580
+ {
581
+ "inputs": [
582
+ {
583
+ "internalType": "address",
584
+ "name": "owner",
585
+ "type": "address"
586
+ },
587
+ {
588
+ "internalType": "address",
589
+ "name": "operator",
590
+ "type": "address"
591
+ }
592
+ ],
593
+ "name": "isApprovedForAll",
594
+ "outputs": [
595
+ {
596
+ "internalType": "bool",
597
+ "name": "",
598
+ "type": "bool"
599
+ }
600
+ ],
601
+ "stateMutability": "view",
602
+ "type": "function"
603
+ },
604
+ {
605
+ "inputs": [
606
+ {
607
+ "internalType": "string",
608
+ "name": "merkleRootHash",
609
+ "type": "string"
610
+ },
611
+ {
612
+ "internalType": "uint256",
613
+ "name": "creationTimestamp",
614
+ "type": "uint256"
615
+ }
616
+ ],
617
+ "name": "isZipFileTokenized",
618
+ "outputs": [
619
+ {
620
+ "internalType": "bool",
621
+ "name": "exists",
622
+ "type": "bool"
623
+ },
624
+ {
625
+ "internalType": "uint256",
626
+ "name": "tokenId",
627
+ "type": "uint256"
628
+ }
629
+ ],
630
+ "stateMutability": "view",
631
+ "type": "function"
632
+ },
633
+ {
634
+ "inputs": [],
635
+ "name": "name",
636
+ "outputs": [
637
+ {
638
+ "internalType": "string",
639
+ "name": "",
640
+ "type": "string"
641
+ }
642
+ ],
643
+ "stateMutability": "view",
644
+ "type": "function"
645
+ },
646
+ {
647
+ "inputs": [],
648
+ "name": "owner",
649
+ "outputs": [
650
+ {
651
+ "internalType": "address",
652
+ "name": "",
653
+ "type": "address"
654
+ }
655
+ ],
656
+ "stateMutability": "view",
657
+ "type": "function"
658
+ },
659
+ {
660
+ "inputs": [
661
+ {
662
+ "internalType": "uint256",
663
+ "name": "tokenId",
664
+ "type": "uint256"
665
+ }
666
+ ],
667
+ "name": "ownerOf",
668
+ "outputs": [
669
+ {
670
+ "internalType": "address",
671
+ "name": "",
672
+ "type": "address"
673
+ }
674
+ ],
675
+ "stateMutability": "view",
676
+ "type": "function"
677
+ },
678
+ {
679
+ "inputs": [
680
+ {
681
+ "internalType": "string",
682
+ "name": "fileName",
683
+ "type": "string"
684
+ },
685
+ {
686
+ "internalType": "string",
687
+ "name": "merkleRootHash",
688
+ "type": "string"
689
+ },
690
+ {
691
+ "internalType": "uint256",
692
+ "name": "creationTimestamp",
693
+ "type": "uint256"
694
+ },
695
+ {
696
+ "internalType": "string",
697
+ "name": "ipfsHash",
698
+ "type": "string"
699
+ },
700
+ {
701
+ "internalType": "string",
702
+ "name": "metadataURI",
703
+ "type": "string"
704
+ }
705
+ ],
706
+ "name": "publicMintZipFile",
707
+ "outputs": [
708
+ {
709
+ "internalType": "uint256",
710
+ "name": "",
711
+ "type": "uint256"
712
+ }
713
+ ],
714
+ "stateMutability": "nonpayable",
715
+ "type": "function"
716
+ },
717
+ {
718
+ "inputs": [],
719
+ "name": "renounceOwnership",
720
+ "outputs": [],
721
+ "stateMutability": "nonpayable",
722
+ "type": "function"
723
+ },
724
+ {
725
+ "inputs": [
726
+ {
727
+ "internalType": "address",
728
+ "name": "from",
729
+ "type": "address"
730
+ },
731
+ {
732
+ "internalType": "address",
733
+ "name": "to",
734
+ "type": "address"
735
+ },
736
+ {
737
+ "internalType": "uint256",
738
+ "name": "tokenId",
739
+ "type": "uint256"
740
+ }
741
+ ],
742
+ "name": "safeTransferFrom",
743
+ "outputs": [],
744
+ "stateMutability": "nonpayable",
745
+ "type": "function"
746
+ },
747
+ {
748
+ "inputs": [
749
+ {
750
+ "internalType": "address",
751
+ "name": "from",
752
+ "type": "address"
753
+ },
754
+ {
755
+ "internalType": "address",
756
+ "name": "to",
757
+ "type": "address"
758
+ },
759
+ {
760
+ "internalType": "uint256",
761
+ "name": "tokenId",
762
+ "type": "uint256"
763
+ },
764
+ {
765
+ "internalType": "bytes",
766
+ "name": "data",
767
+ "type": "bytes"
768
+ }
769
+ ],
770
+ "name": "safeTransferFrom",
771
+ "outputs": [],
772
+ "stateMutability": "nonpayable",
773
+ "type": "function"
774
+ },
775
+ {
776
+ "inputs": [
777
+ {
778
+ "internalType": "address",
779
+ "name": "operator",
780
+ "type": "address"
781
+ },
782
+ {
783
+ "internalType": "bool",
784
+ "name": "approved",
785
+ "type": "bool"
786
+ }
787
+ ],
788
+ "name": "setApprovalForAll",
789
+ "outputs": [],
790
+ "stateMutability": "nonpayable",
791
+ "type": "function"
792
+ },
793
+ {
794
+ "inputs": [
795
+ {
796
+ "internalType": "bytes4",
797
+ "name": "interfaceId",
798
+ "type": "bytes4"
799
+ }
800
+ ],
801
+ "name": "supportsInterface",
802
+ "outputs": [
803
+ {
804
+ "internalType": "bool",
805
+ "name": "",
806
+ "type": "bool"
807
+ }
808
+ ],
809
+ "stateMutability": "view",
810
+ "type": "function"
811
+ },
812
+ {
813
+ "inputs": [],
814
+ "name": "symbol",
815
+ "outputs": [
816
+ {
817
+ "internalType": "string",
818
+ "name": "",
819
+ "type": "string"
820
+ }
821
+ ],
822
+ "stateMutability": "view",
823
+ "type": "function"
824
+ },
825
+ {
826
+ "inputs": [
827
+ {
828
+ "internalType": "uint256",
829
+ "name": "tokenId",
830
+ "type": "uint256"
831
+ }
832
+ ],
833
+ "name": "tokenURI",
834
+ "outputs": [
835
+ {
836
+ "internalType": "string",
837
+ "name": "",
838
+ "type": "string"
839
+ }
840
+ ],
841
+ "stateMutability": "view",
842
+ "type": "function"
843
+ },
844
+ {
845
+ "inputs": [],
846
+ "name": "totalSupply",
847
+ "outputs": [
848
+ {
849
+ "internalType": "uint256",
850
+ "name": "",
851
+ "type": "uint256"
852
+ }
853
+ ],
854
+ "stateMutability": "view",
855
+ "type": "function"
856
+ },
857
+ {
858
+ "inputs": [
859
+ {
860
+ "internalType": "address",
861
+ "name": "from",
862
+ "type": "address"
863
+ },
864
+ {
865
+ "internalType": "address",
866
+ "name": "to",
867
+ "type": "address"
868
+ },
869
+ {
870
+ "internalType": "uint256",
871
+ "name": "tokenId",
872
+ "type": "uint256"
873
+ }
874
+ ],
875
+ "name": "transferFrom",
876
+ "outputs": [],
877
+ "stateMutability": "nonpayable",
878
+ "type": "function"
879
+ },
880
+ {
881
+ "inputs": [
882
+ {
883
+ "internalType": "address",
884
+ "name": "newOwner",
885
+ "type": "address"
886
+ }
887
+ ],
888
+ "name": "transferOwnership",
889
+ "outputs": [],
890
+ "stateMutability": "nonpayable",
891
+ "type": "function"
892
+ },
893
+ {
894
+ "inputs": [
895
+ {
896
+ "internalType": "uint256",
897
+ "name": "tokenId",
898
+ "type": "uint256"
899
+ },
900
+ {
901
+ "internalType": "string",
902
+ "name": "providedMerkleRoot",
903
+ "type": "string"
904
+ }
905
+ ],
906
+ "name": "verifyZipFile",
907
+ "outputs": [
908
+ {
909
+ "internalType": "bool",
910
+ "name": "isValid",
911
+ "type": "bool"
912
+ }
913
+ ],
914
+ "stateMutability": "view",
915
+ "type": "function"
916
+ },
917
+ {
918
+ "inputs": [
919
+ {
920
+ "internalType": "uint256",
921
+ "name": "",
922
+ "type": "uint256"
923
+ }
924
+ ],
925
+ "name": "zipFileInfo",
926
+ "outputs": [
927
+ {
928
+ "internalType": "string",
929
+ "name": "fileName",
930
+ "type": "string"
931
+ },
932
+ {
933
+ "internalType": "string",
934
+ "name": "merkleRootHash",
935
+ "type": "string"
936
+ },
937
+ {
938
+ "internalType": "string",
939
+ "name": "ipfsHash",
940
+ "type": "string"
941
+ },
942
+ {
943
+ "internalType": "address",
944
+ "name": "creator",
945
+ "type": "address"
946
+ },
947
+ {
948
+ "internalType": "uint256",
949
+ "name": "creationTimestamp",
950
+ "type": "uint256"
951
+ },
952
+ {
953
+ "internalType": "uint256",
954
+ "name": "tokenizationTime",
955
+ "type": "uint256"
956
+ },
957
+ {
958
+ "internalType": "uint256",
959
+ "name": "blockNumber",
960
+ "type": "uint256"
961
+ }
962
+ ],
963
+ "stateMutability": "view",
964
+ "type": "function"
965
+ }
966
+ ];
967
+
968
+ return { bytecode, abi };
969
+ }
970
+
971
+ async function deployContract() {
972
+ console.log('🌐 NZIP NFT Public Contract Deployment');
973
+ console.log('=====================================');
974
+
975
+ // Check if user has a deprecated contract configured
976
+ if (EXISTING_CONTRACT) {
977
+ console.log(`āš ļø Deprecated contract detected in config: ${EXISTING_CONTRACT}`);
978
+ console.log('šŸ“‹ This contract is no longer supported and should not be used.');
979
+ console.log('šŸ“‹ Proceeding with new contract deployment...\n');
980
+ }
981
+
982
+ // Validate configuration
983
+ if (!PRIVATE_KEY) {
984
+ console.log('āŒ PRIVATE_KEY is required for deployment.');
985
+ console.log('šŸ“ Set it in environment variable or deployment.config.js');
986
+ console.log('šŸ“ Example: PRIVATE_KEY=your_private_key_without_0x_prefix');
987
+ throw new Error('āŒ PRIVATE_KEY environment variable is required');
988
+ }
989
+
990
+ if (!NETWORK_CONFIG[CHAIN_ID]) {
991
+ throw new Error(`āŒ Unsupported chain ID: ${CHAIN_ID}`);
992
+ }
993
+
994
+ const networkConfig = NETWORK_CONFIG[CHAIN_ID];
995
+ console.log(`🌐 Network: ${networkConfig.name}`);
996
+ console.log(`šŸ”— RPC URL: ${networkConfig.rpcUrl}`);
997
+ console.log(`šŸ” Explorer: ${networkConfig.explorer}\n`);
998
+
999
+ // Load contract data
1000
+ console.log('šŸ“‹ Loading contract bytecode...');
1001
+ const { bytecode, abi } = loadContractData();
1002
+ console.log(`āœ… Bytecode loaded (${bytecode.length} characters)`);
1003
+
1004
+ // Setup provider and wallet
1005
+ const provider = new ethers.JsonRpcProvider(networkConfig.rpcUrl);
1006
+ const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
1007
+
1008
+ console.log(`šŸ‘¤ Deployer address: ${wallet.address}`);
1009
+
1010
+ // Check balance
1011
+ const balance = await provider.getBalance(wallet.address);
1012
+ console.log(`šŸ’° Balance: ${ethers.formatEther(balance)} ETH`);
1013
+
1014
+ if (balance === 0n) {
1015
+ throw new Error('āŒ Insufficient balance for deployment');
1016
+ }
1017
+
1018
+ // Create contract factory
1019
+ const contractFactory = new ethers.ContractFactory(abi, bytecode, wallet);
1020
+
1021
+ console.log('\nšŸš€ Deploying contract...');
1022
+
1023
+ // Deploy the contract
1024
+ const contract = await contractFactory.deploy();
1025
+
1026
+ console.log(`šŸ“ Transaction hash: ${contract.deploymentTransaction().hash}`);
1027
+ console.log('ā³ Waiting for deployment confirmation...');
1028
+
1029
+ // Wait for deployment
1030
+ await contract.waitForDeployment();
1031
+
1032
+ const contractAddress = await contract.getAddress();
1033
+
1034
+ console.log('\nšŸŽ‰ Contract deployed successfully!');
1035
+ console.log('=====================================');
1036
+ console.log(`šŸ“ Contract Address: ${contractAddress}`);
1037
+ console.log(`🌐 Network: ${networkConfig.name}`);
1038
+ console.log(`šŸ” Explorer: ${networkConfig.explorer}/address/${contractAddress}`);
1039
+
1040
+ // Test the contract
1041
+ try {
1042
+ const version = await contract.getVersion();
1043
+ console.log(`šŸ“‹ Contract Version: ${version}`);
1044
+ } catch (err) {
1045
+ console.log('āš ļø Warning: Could not verify contract version');
1046
+ }
1047
+
1048
+ console.log('\nāœ… Deployment completed successfully!');
1049
+ console.log(`šŸ“‹ Save this address: ${contractAddress}`);
1050
+
1051
+ return contractAddress;
1052
+ }
1053
+
1054
+ // Run deployment
1055
+ deployContract()
1056
+ .then((address) => {
1057
+ console.log(`\nšŸŽÆ Final contract address: ${address}`);
1058
+ process.exit(0);
1059
+ })
1060
+ .catch((error) => {
1061
+ console.error('\nāŒ Deployment failed:', error.message);
1062
+ process.exit(1);
1063
+ });