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.
- package/README.md +400 -0
- package/contracts/Lock.sol +34 -0
- package/contracts/bytecode.txt +1 -0
- package/contracts/compile-contract.js +168 -0
- package/contracts/deploy/deploy-both-contracts.js +286 -0
- package/contracts/deploy/deploy-enhanced-contract.js +197 -0
- package/contracts/deploy/deploy-private-contract.js +190 -0
- package/contracts/deploy/deploy-public-clean.js +1063 -0
- package/contracts/deploy/deploy-public-contract.js +1107 -0
- package/contracts/deployment.config.example.js +25 -0
- package/contracts/remix-compile.js +222 -0
- package/contracts/setup-deployment.js +51 -0
- package/contracts/src/NZIP-NFT-Private.sol +350 -0
- package/contracts/src/NZIP-NFT.sol +265 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +260 -0
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +289 -0
- package/dist/browser/CertificateGeneratorBrowser.d.ts +75 -0
- package/dist/browser/CertificateGeneratorBrowser.js +433 -0
- package/dist/browser/TokenVerifierBrowser.d.ts +76 -0
- package/dist/browser/TokenVerifierBrowser.js +299 -0
- package/dist/browser/ZipKitBrowser.d.ts +18 -0
- package/dist/browser/ZipKitBrowser.js +250 -0
- package/dist/browser/ZipKitStampBrowser.d.ts +2 -0
- package/dist/browser/ZipKitStampBrowser.js +12 -0
- package/dist/browser-index.d.ts +21 -0
- package/dist/browser-index.js +58 -0
- package/dist/browser.d.ts +21 -0
- package/dist/browser.js +58 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +76 -0
- package/dist/server/blockchain/CertificateToken.d.ts +48 -0
- package/dist/server/blockchain/CertificateToken.js +386 -0
- package/dist/server/blockchain/NFTMinter.d.ts +41 -0
- package/dist/server/blockchain/NFTMinter.js +323 -0
- package/dist/server/blockchain/TokenQuerier.d.ts +31 -0
- package/dist/server/blockchain/TokenQuerier.js +259 -0
- package/dist/server/blockchain/TokenVerifier.d.ts +20 -0
- package/dist/server/blockchain/TokenVerifier.js +395 -0
- package/dist/server/blockchain/WalletAnalyzer.d.ts +81 -0
- package/dist/server/blockchain/WalletAnalyzer.js +356 -0
- package/dist/server/blockchain/WalletFormatter.d.ts +39 -0
- package/dist/server/blockchain/WalletFormatter.js +196 -0
- package/dist/server/blockchain/WalletManager.d.ts +46 -0
- package/dist/server/blockchain/WalletManager.js +294 -0
- package/dist/server/blockchain/ZipMetadata.d.ts +27 -0
- package/dist/server/blockchain/ZipMetadata.js +131 -0
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +44 -0
- package/dist/server/blockchain/ZipTokenProcessor.js +204 -0
- package/dist/server/blockchain/constants.d.ts +102 -0
- package/dist/server/blockchain/constants.js +968 -0
- package/dist/server/blockchain/index.d.ts +9 -0
- package/dist/server/blockchain/index.js +44 -0
- package/dist/server/blockchain/test-certificate.d.ts +8 -0
- package/dist/server/blockchain/test-certificate.js +100 -0
- package/dist/server/blockchain/types.d.ts +69 -0
- package/dist/server/blockchain/types.js +51 -0
- package/dist/server/platform/server/ZipKitServer.d.ts +105 -0
- package/dist/server/platform/server/ZipKitServer.js +437 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +91 -0
- package/dist/server/platform/servercomponents/ZipKitOTS.js +271 -0
- package/dist/shared/ZipEntry.d.ts +131 -0
- package/dist/shared/ZipEntry.js +686 -0
- package/dist/shared/ZipKit.d.ts +249 -0
- package/dist/shared/ZipKit.js +789 -0
- package/dist/shared/components/CertificateOTS.d.ts +15 -0
- package/dist/shared/components/CertificateOTS.js +116 -0
- package/dist/shared/components/FileSys.d.ts +2 -0
- package/dist/shared/components/FileSys.js +113 -0
- package/dist/shared/components/HashAccumulator.d.ts +55 -0
- package/dist/shared/components/HashAccumulator.js +100 -0
- package/dist/shared/components/Support.d.ts +63 -0
- package/dist/shared/components/Support.js +70 -0
- package/dist/shared/components/Util.d.ts +21 -0
- package/dist/shared/components/Util.js +115 -0
- package/dist/shared/components/ZipCrypto.d.ts +3 -0
- package/dist/shared/components/ZipCrypto.js +78 -0
- package/dist/shared/components/merkleTree.d.ts +66 -0
- package/dist/shared/components/merkleTree.js +136 -0
- package/dist/shared/constants/Errors.d.ts +53 -0
- package/dist/shared/constants/Errors.js +69 -0
- package/dist/shared/constants/Headers.d.ts +167 -0
- package/dist/shared/constants/Headers.js +191 -0
- package/dist/shared/types/index.d.ts +21 -0
- package/dist/shared/types/index.js +3 -0
- package/dist/shared/types.d.ts +33 -0
- package/dist/shared/types.js +8 -0
- package/dist/shared/version.d.ts +4 -0
- package/dist/shared/version.js +7 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.js +3 -0
- package/examples/unzip-token.ts +488 -0
- package/examples/zip-token.ts +604 -0
- package/package.json +117 -0
- package/src/browser/CertificateGeneratorBrowser.ts +498 -0
- package/src/browser/TokenVerifierBrowser.ts +344 -0
- package/src/browser/ZipKitBrowser.ts +242 -0
- package/src/browser/ZipKitStampBrowser.ts +9 -0
- package/src/browser-index.ts +36 -0
- package/src/index.ts +48 -0
- package/src/server/blockchain/CertificateToken.ts +444 -0
- package/src/server/blockchain/NFTMinter.ts +357 -0
- package/src/server/blockchain/TokenQuerier.ts +287 -0
- package/src/server/blockchain/TokenVerifier.ts +453 -0
- package/src/server/blockchain/WalletAnalyzer.ts +397 -0
- package/src/server/blockchain/WalletFormatter.ts +206 -0
- package/src/server/blockchain/WalletManager.ts +294 -0
- package/src/server/blockchain/ZipMetadata.ts +117 -0
- package/src/server/blockchain/ZipTokenProcessor.ts +234 -0
- package/src/server/blockchain/constants.ts +969 -0
- package/src/server/blockchain/index.ts +42 -0
- package/src/server/blockchain/test-certificate.ts +137 -0
- package/src/server/blockchain/types.ts +134 -0
- package/src/server/platform/server/ZipKitServer.ts +459 -0
- package/src/server/platform/servercomponents/ZipKitOTS.ts +313 -0
- package/src/server/platform/servercomponents/opentimestamps.d.ts +23 -0
- package/src/shared/ZipEntry.ts +767 -0
- package/src/shared/ZipKit.ts +899 -0
- package/src/shared/components/CertificateOTS.ts +132 -0
- package/src/shared/components/FileSys.ts +87 -0
- package/src/shared/components/HashAccumulator.ts +113 -0
- package/src/shared/components/Support.ts +77 -0
- package/src/shared/components/Util.ts +113 -0
- package/src/shared/components/ZipCrypto.ts +91 -0
- package/src/shared/components/merkleTree.ts +162 -0
- package/src/shared/constants/Errors.ts +82 -0
- package/src/shared/constants/Headers.ts +203 -0
- package/src/shared/types/index.ts +25 -0
- package/src/shared/types/modules.d.ts +22 -0
- package/src/shared/types/opentimestamps.d.ts +23 -0
- package/src/shared/types.d.ts +8 -0
- package/src/shared/types.ts +43 -0
- package/src/shared/version.ts +4 -0
- package/src/types/index.ts +25 -0
- package/src/types/modules.d.ts +22 -0
- package/src/types/opentimestamps.d.ts +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
# neozipkit
|
|
2
|
+
|
|
3
|
+
Advanced ZIP file creation and verification library with blockchain timestamping and NFT tokenization capabilities.
|
|
4
|
+
|
|
5
|
+
## š Features
|
|
6
|
+
|
|
7
|
+
- **Advanced ZIP compression** with support for multiple compression methods (Deflate, ZStandard, Stored)
|
|
8
|
+
- **Blockchain timestamping** using OpenTimestamps for file integrity verification
|
|
9
|
+
- **NFT tokenization** for creating blockchain-backed ZIP file certificates
|
|
10
|
+
- **Hash-based verification** with Merkle tree support
|
|
11
|
+
- **Browser and server compatibility** with clean platform separation
|
|
12
|
+
- **TypeScript support** with full type definitions
|
|
13
|
+
|
|
14
|
+
## š¦ Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
yarn add neozipkit
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## š Quick Start
|
|
21
|
+
|
|
22
|
+
### Basic ZIP Creation
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { ZipKitBrowser } from 'neozipkit/browser';
|
|
26
|
+
import { CompressOptions } from 'neozipkit';
|
|
27
|
+
|
|
28
|
+
const zipKit = new ZipKitBrowser();
|
|
29
|
+
const options: CompressOptions = {
|
|
30
|
+
useZstd: false, // Use deflate compression
|
|
31
|
+
level: 6
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Add files to ZIP
|
|
35
|
+
await zipKit.addFile('example.txt', fileBuffer, options);
|
|
36
|
+
const zipBuffer = await zipKit.finalize();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### ZIP Verification
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { ZipKitBrowser } from 'neozipkit/browser';
|
|
43
|
+
import { ZipEntry } from 'neozipkit';
|
|
44
|
+
|
|
45
|
+
const zipKit = new ZipKitBrowser();
|
|
46
|
+
const entries: ZipEntry[] = await zipKit.loadFromBuffer(zipBuffer);
|
|
47
|
+
|
|
48
|
+
// Verify file integrity
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const isValid = await zipKit.verifyEntry(entry);
|
|
51
|
+
console.log(`${entry.filename}: ${isValid ? 'Valid' : 'Invalid'}`);
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## šļø Package Architecture
|
|
56
|
+
|
|
57
|
+
### Unified Directory Structure
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
packages/neozipkit/
|
|
61
|
+
āāā src/ # TypeScript source files
|
|
62
|
+
ā āāā browser/ # Browser-only implementations
|
|
63
|
+
ā ā āāā ZipKitBrowser.ts
|
|
64
|
+
ā ā āāā CertificateGeneratorBrowser.ts
|
|
65
|
+
ā ā āāā TokenVerifierBrowser.ts
|
|
66
|
+
ā āāā server/ # Server-only implementations
|
|
67
|
+
ā ā āāā blockchain/ # Blockchain integration utilities
|
|
68
|
+
ā ā ā āāā TokenVerifier.ts # Verify tokenized ZIP files
|
|
69
|
+
ā ā ā āāā NFTMinter.ts # Mint NFTs for ZIP files
|
|
70
|
+
ā ā ā āāā WalletManager.ts # Manage wallet connections
|
|
71
|
+
ā ā ā āāā ... # Additional blockchain components
|
|
72
|
+
ā ā āāā platform/ # Server platform code
|
|
73
|
+
ā ā āāā server/ # Server-specific ZIP operations
|
|
74
|
+
ā ā āāā servercomponents/ # OpenTimestamps & server utilities
|
|
75
|
+
ā āāā shared/ # Shared utilities
|
|
76
|
+
ā ā āāā components/ # Core ZIP utilities
|
|
77
|
+
ā ā āāā constants/ # Headers, errors, etc.
|
|
78
|
+
ā ā āāā types/ # Type definitions
|
|
79
|
+
ā ā āāā ZipKit.ts # Main ZipKit class
|
|
80
|
+
ā ā āāā ZipEntry.ts # ZIP entry handling
|
|
81
|
+
ā āāā browser-index.ts # Browser-specific exports
|
|
82
|
+
ā āāā index.ts # Main exports (all platforms)
|
|
83
|
+
āāā dist/ # Compiled JavaScript output
|
|
84
|
+
ā āāā browser.js/.d.ts # Browser-only bundle
|
|
85
|
+
ā āāā server/ # Server bundle
|
|
86
|
+
ā āāā shared/ # Shared code
|
|
87
|
+
ā āāā index.js/.d.ts # Main bundle
|
|
88
|
+
āāā contracts/ # Smart contracts for NFT tokenization
|
|
89
|
+
āāā examples/ # Usage examples
|
|
90
|
+
āāā docs/ # Documentation
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## š Import Patterns
|
|
94
|
+
|
|
95
|
+
### Browser Applications (Recommended)
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// Browser-only bundle (excludes Node.js dependencies)
|
|
99
|
+
import { ZipKitBrowser, CertificateGeneratorBrowser } from 'neozipkit/browser';
|
|
100
|
+
import { TOKENIZED_METADATA } from 'neozipkit/browser';
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Universal Applications (Next.js, Node.js)
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Main bundle (includes both browser and server when possible)
|
|
107
|
+
import { ZipKitBrowser, CertificateGeneratorBrowser } from 'neozipkit';
|
|
108
|
+
import { TOKENIZED_METADATA } from 'neozipkit/shared/constants/Headers';
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Server-Only Components (Node.js)
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// Direct TypeScript imports for server components
|
|
115
|
+
import { TokenVerifier } from 'neozipkit/server/blockchain/TokenVerifier';
|
|
116
|
+
import { ZipKitOTS } from 'neozipkit/server/platform/servercomponents/ZipKitOTS';
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## š Blockchain Integration
|
|
120
|
+
|
|
121
|
+
NeoZipKit includes comprehensive blockchain integration for creating and verifying tokenized ZIP files on Ethereum-compatible networks.
|
|
122
|
+
|
|
123
|
+
### Supported Features
|
|
124
|
+
|
|
125
|
+
- **NFT Tokenization**: Convert ZIP files into ERC-721 NFTs with complete metadata
|
|
126
|
+
- **Blockchain Verification**: Verify ZIP file authenticity against blockchain tokens
|
|
127
|
+
- **OpenTimestamps**: Bitcoin blockchain timestamping for file integrity
|
|
128
|
+
- **Multi-Network Support**: Base Mainnet, Base Sepolia, Ethereum, Polygon, Arbitrum
|
|
129
|
+
- **Smart Contracts**: Production-ready contracts for public and private tokenization
|
|
130
|
+
|
|
131
|
+
### Blockchain Components
|
|
132
|
+
|
|
133
|
+
- **`TokenVerifier`** - Verify tokenized ZIP files against blockchain
|
|
134
|
+
- **`NFTMinter`** - Mint NFTs for ZIP files
|
|
135
|
+
- **`TokenQuerier`** - Query token information from blockchain
|
|
136
|
+
- **`CertificateToken`** - Generate certificates for tokenized files
|
|
137
|
+
- **`ZipTokenProcessor`** - Process ZIP files for tokenization
|
|
138
|
+
- **`WalletManager`** - Manage wallet connections and networks
|
|
139
|
+
|
|
140
|
+
### Usage Example
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import { ZipTokenProcessor, MintingOptions } from 'neozipkit/server/blockchain';
|
|
144
|
+
|
|
145
|
+
const options: MintingOptions = {
|
|
146
|
+
wallet: 'path/to/wallet.json',
|
|
147
|
+
network: 'base-sepolia',
|
|
148
|
+
mintToken: true
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const processor = new ZipTokenProcessor('archive.zip', 'merkle_root_hash', options);
|
|
152
|
+
const result = await processor.processZipToken(options);
|
|
153
|
+
|
|
154
|
+
if (result.error) {
|
|
155
|
+
console.error('Processing failed:', result.error);
|
|
156
|
+
} else {
|
|
157
|
+
console.log('Success!', result);
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## šÆ Smart Contracts
|
|
162
|
+
|
|
163
|
+
The package includes production-ready smart contracts for ZIP file tokenization:
|
|
164
|
+
|
|
165
|
+
### Contract Types
|
|
166
|
+
|
|
167
|
+
#### š Public Contract (`NZIP-NFT.sol`)
|
|
168
|
+
- **Universal verification** - Anyone can verify any token
|
|
169
|
+
- **Public blockchain metadata** - All data visible on blockchain
|
|
170
|
+
- **Use cases**: Certificates, public records, open-source projects
|
|
171
|
+
- **Symbol**: `NZIP`
|
|
172
|
+
|
|
173
|
+
#### š Private Contract (`NZIP-NFT-Private.sol`)
|
|
174
|
+
- **Owner-only verification** - Only token owners can verify their tokens
|
|
175
|
+
- **Private blockchain metadata** - Sensitive data hidden from public
|
|
176
|
+
- **Selective authorization** - Owners can authorize specific verifiers
|
|
177
|
+
- **Use cases**: Medical records, legal documents, private archives
|
|
178
|
+
- **Symbol**: `NZIPPRV`
|
|
179
|
+
|
|
180
|
+
### Current Deployment
|
|
181
|
+
|
|
182
|
+
**ā
Production Contract (v2.0)**:
|
|
183
|
+
```
|
|
184
|
+
Address: 0xFD76a5d420704F34d84b0767961835c43D7b30a8
|
|
185
|
+
Network: Base Sepolia
|
|
186
|
+
Version: 2.0.0
|
|
187
|
+
Status: ā
ACTIVE - Use for all new integrations
|
|
188
|
+
Explorer: https://sepolia.basescan.org/address/0xFD76a5d420704F34d84b0767961835c43D7b30a8
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Contract Deployment
|
|
192
|
+
|
|
193
|
+
Deploy your own contracts using the included scripts:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Setup deployment configuration
|
|
197
|
+
npm run setup-deployment
|
|
198
|
+
|
|
199
|
+
# Deploy both contracts (public + private)
|
|
200
|
+
npm run deploy:both
|
|
201
|
+
|
|
202
|
+
# Deploy only public contract
|
|
203
|
+
npm run deploy:public
|
|
204
|
+
|
|
205
|
+
# Deploy to mainnet
|
|
206
|
+
npm run deploy:both:mainnet
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## š§ Development Workflow
|
|
210
|
+
|
|
211
|
+
### Build Process
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Full build process
|
|
215
|
+
npm run build
|
|
216
|
+
|
|
217
|
+
# Individual steps
|
|
218
|
+
npm run clean # Remove compiled files
|
|
219
|
+
npm run compile # TypeScript compilation
|
|
220
|
+
npm run watch # Watch mode for development
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
This runs:
|
|
224
|
+
1. `npm run clean` - Removes old compiled files
|
|
225
|
+
2. `npm run compile` - Compiles TypeScript to dist/
|
|
226
|
+
3. `npm run create-browser-entry` - Creates browser-only bundle
|
|
227
|
+
|
|
228
|
+
### TypeScript Configuration
|
|
229
|
+
|
|
230
|
+
- **Target**: ES2020
|
|
231
|
+
- **Module**: CommonJS
|
|
232
|
+
- **Source**: `./src`
|
|
233
|
+
- **Output**: `./dist`
|
|
234
|
+
- **Declarations**: Generated alongside JavaScript files
|
|
235
|
+
|
|
236
|
+
## š API Reference
|
|
237
|
+
|
|
238
|
+
### Core Classes
|
|
239
|
+
|
|
240
|
+
- **`ZipKit`** - Core ZIP functionality (shared)
|
|
241
|
+
- **`ZipKitBrowser`** - Browser-compatible ZIP operations
|
|
242
|
+
- **`ZipKitServer`** - Server-side ZIP operations with full Node.js support
|
|
243
|
+
- **`ZipEntry`** - ZIP entry representation and manipulation
|
|
244
|
+
- **`HashAccumulator`** - Hash accumulation for Merkle tree verification
|
|
245
|
+
|
|
246
|
+
### Platform-Specific Components
|
|
247
|
+
|
|
248
|
+
#### Browser Components
|
|
249
|
+
- **`CertificateGeneratorBrowser`** - Generate verification certificates
|
|
250
|
+
- **`TokenVerifierBrowser`** - Browser-based token verification
|
|
251
|
+
- **`ZipKitStampBrowser`** - Browser timestamping utilities
|
|
252
|
+
|
|
253
|
+
#### Server Components
|
|
254
|
+
- **`ZipKitOTS`** - OpenTimestamps integration
|
|
255
|
+
- **Blockchain Classes** - Complete blockchain integration suite
|
|
256
|
+
|
|
257
|
+
### Constants and Types
|
|
258
|
+
|
|
259
|
+
- **`constants/Headers`** - ZIP header constants and compression methods
|
|
260
|
+
- **`constants/Errors`** - Error definitions
|
|
261
|
+
- **`shared/types`** - TypeScript type definitions
|
|
262
|
+
- **`CMP_METHOD`** - Compression method constants
|
|
263
|
+
|
|
264
|
+
### Compression Methods
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import { CMP_METHOD } from 'neozipkit/shared/constants/Headers';
|
|
268
|
+
|
|
269
|
+
// Available compression methods
|
|
270
|
+
const compressionType = entry.cmpMethod;
|
|
271
|
+
|
|
272
|
+
if (compressionType === CMP_METHOD.ZSTD) {
|
|
273
|
+
console.log('ZStandard compression');
|
|
274
|
+
} else if (compressionType === CMP_METHOD.DEFLATED) {
|
|
275
|
+
console.log('Deflate compression');
|
|
276
|
+
} else if (compressionType === CMP_METHOD.STORED) {
|
|
277
|
+
console.log('No compression');
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Hash Accumulation
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
import { HashAccumulator } from 'neozipkit/shared/components/HashAccumulator';
|
|
285
|
+
|
|
286
|
+
const accumulator = new HashAccumulator();
|
|
287
|
+
accumulator.addFile('example.txt', fileBuffer);
|
|
288
|
+
const merkleRoot = accumulator.finalize();
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## š Network Support
|
|
292
|
+
|
|
293
|
+
### Supported Networks
|
|
294
|
+
|
|
295
|
+
- **Base Sepolia** (Chain ID: 84532) - Testing
|
|
296
|
+
- **Base Mainnet** (Chain ID: 8453) - Production
|
|
297
|
+
- **Ethereum Mainnet** - Production
|
|
298
|
+
- **Polygon** - Production
|
|
299
|
+
- **Arbitrum** - Production
|
|
300
|
+
|
|
301
|
+
### Network Configuration
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// Networks are configured in blockchain components
|
|
305
|
+
const networkConfig = {
|
|
306
|
+
'base': {
|
|
307
|
+
chainId: 8453,
|
|
308
|
+
rpcUrl: 'https://mainnet.base.org',
|
|
309
|
+
explorer: 'https://basescan.org'
|
|
310
|
+
},
|
|
311
|
+
'base-sepolia': {
|
|
312
|
+
chainId: 84532,
|
|
313
|
+
rpcUrl: 'https://sepolia.base.org',
|
|
314
|
+
explorer: 'https://sepolia.basescan.org'
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## š Security Considerations
|
|
320
|
+
|
|
321
|
+
### Development Best Practices
|
|
322
|
+
|
|
323
|
+
- **Private Keys**: Never commit private keys or mnemonics to version control
|
|
324
|
+
- **Network Security**: Use secure RPC endpoints and validate all inputs
|
|
325
|
+
- **Smart Contract Audits**: Audit contracts before production deployment
|
|
326
|
+
- **Error Handling**: Implement comprehensive error handling for all operations
|
|
327
|
+
- **Type Safety**: Leverage TypeScript for compile-time error detection
|
|
328
|
+
|
|
329
|
+
### File Verification
|
|
330
|
+
|
|
331
|
+
- **Merkle Trees**: All ZIP files use cryptographic Merkle trees for integrity verification
|
|
332
|
+
- **Blockchain Anchoring**: Timestamps and hashes are anchored to blockchain networks
|
|
333
|
+
- **Multi-Layer Verification**: Support for both OpenTimestamps and NFT-based verification
|
|
334
|
+
|
|
335
|
+
## š¦ Dependencies
|
|
336
|
+
|
|
337
|
+
### Core Dependencies
|
|
338
|
+
|
|
339
|
+
- **`ethers`** (peer dependency) - Blockchain operations
|
|
340
|
+
- **`opentimestamps`** - Bitcoin blockchain timestamping
|
|
341
|
+
- **`uuid`** - Unique identifier generation
|
|
342
|
+
- **`web3`** (peer dependency) - Alternative blockchain interface
|
|
343
|
+
|
|
344
|
+
### Development Dependencies
|
|
345
|
+
|
|
346
|
+
- **`@types/node`** - Node.js type definitions
|
|
347
|
+
- **`typescript`** - TypeScript compiler
|
|
348
|
+
|
|
349
|
+
## š Migration Guide
|
|
350
|
+
|
|
351
|
+
### From Previous Versions
|
|
352
|
+
|
|
353
|
+
If upgrading from previous versions:
|
|
354
|
+
|
|
355
|
+
1. **Update Import Paths**:
|
|
356
|
+
```typescript
|
|
357
|
+
// OLD
|
|
358
|
+
import { TokenVerifier } from 'neozipkit/server-components/blockchain/TokenVerifier';
|
|
359
|
+
|
|
360
|
+
// NEW
|
|
361
|
+
import { checkForTokenizationServer } from 'neozipkit/server/blockchain/TokenVerifier';
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
2. **Browser Imports**: Replace main package imports with browser-specific imports for browser applications
|
|
365
|
+
3. **Contract Addresses**: Update to use the new production contract address
|
|
366
|
+
4. **Build Process**: Remove any manual copying scripts - everything now uses TypeScript compilation
|
|
367
|
+
|
|
368
|
+
## š¤ Contributing
|
|
369
|
+
|
|
370
|
+
### Development Setup
|
|
371
|
+
|
|
372
|
+
1. Clone the repository and install dependencies
|
|
373
|
+
2. Make changes to TypeScript files in `src/`
|
|
374
|
+
3. Run `npm run build` to compile changes
|
|
375
|
+
4. Test changes in consuming applications
|
|
376
|
+
5. Commit only source files, not generated files
|
|
377
|
+
|
|
378
|
+
### Making Changes
|
|
379
|
+
|
|
380
|
+
- Edit TypeScript files in `src/` directories
|
|
381
|
+
- Update exports in `src/index.ts` if adding new public modules
|
|
382
|
+
- Update `package.json` exports if creating new public modules
|
|
383
|
+
- Run build process to generate JavaScript
|
|
384
|
+
- Test in portal application
|
|
385
|
+
|
|
386
|
+
## š License
|
|
387
|
+
|
|
388
|
+
MIT
|
|
389
|
+
|
|
390
|
+
## š Getting Started
|
|
391
|
+
|
|
392
|
+
Ready to start using NeoZipKit? Here are some next steps:
|
|
393
|
+
|
|
394
|
+
1. **Install the package**: `yarn add neozipkit`
|
|
395
|
+
2. **Choose your use case**: Basic ZIP operations, OpenTimestamps, or NFT tokenization
|
|
396
|
+
3. **Follow the examples**: Check the `examples/` directory for complete implementations
|
|
397
|
+
4. **Deploy contracts**: Use the deployment scripts for blockchain features
|
|
398
|
+
5. **Build something amazing**: Leverage the full power of blockchain-backed file verification
|
|
399
|
+
|
|
400
|
+
For detailed examples and advanced usage, explore the examples directory and blockchain integration documentation.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
pragma solidity ^0.8.28;
|
|
3
|
+
|
|
4
|
+
// Uncomment this line to use console.log
|
|
5
|
+
// import "hardhat/console.sol";
|
|
6
|
+
|
|
7
|
+
contract Lock {
|
|
8
|
+
uint public unlockTime;
|
|
9
|
+
address payable public owner;
|
|
10
|
+
|
|
11
|
+
event Withdrawal(uint amount, uint when);
|
|
12
|
+
|
|
13
|
+
constructor(uint _unlockTime) payable {
|
|
14
|
+
require(
|
|
15
|
+
block.timestamp < _unlockTime,
|
|
16
|
+
"Unlock time should be in the future"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
unlockTime = _unlockTime;
|
|
20
|
+
owner = payable(msg.sender);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function withdraw() public {
|
|
24
|
+
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
|
|
25
|
+
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);
|
|
26
|
+
|
|
27
|
+
require(block.timestamp >= unlockTime, "You can't withdraw yet");
|
|
28
|
+
require(msg.sender == owner, "You aren't the owner");
|
|
29
|
+
|
|
30
|
+
emit Withdrawal(address(this).balance, block.timestamp);
|
|
31
|
+
|
|
32
|
+
owner.transfer(address(this).balance);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
608060405234801561000f575f5ffd5b5033604051806040016040528060128152602001712732b7ad34b8102334b6329027232a103b1960711b8152506040518060400160405280600481526020016304e5a49560e41b815250815f9081610067919061019c565b506001610074828261019c565b5050506001600160a01b0381166100a457604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6100ad816100b3565b50610256565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b634e487b7160e01b5f52604160045260245ffd5b600181811c9082168061012c57607f821691505b60208210810361014a57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561019757805f5260205f20601f840160051c810160208510156101755750805b601f840160051c820191505b81811015610194575f8155600101610181565b50505b505050565b81516001600160401b038111156101b5576101b5610104565b6101c9816101c38454610118565b84610150565b6020601f8211600181146101fb575f83156101e45750848201515b5f19600385901b1c1916600184901b178455610194565b5f84815260208120601f198516915b8281101561022a578785015182556020948501946001909201910161020a565b508482101561024757868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b612549806102635f395ff3fe608060405234801561000f575f5ffd5b50600436106101a0575f3560e01c806370d4d9fd116100f3578063a5e20a9c11610093578063ca3685d91161006e578063ca3685d9146103c4578063e985e9c5146103ea578063f2fde38b146103fd578063fe974bfe14610410575f5ffd5b8063a5e20a9c1461037f578063b88d4fde1461039e578063c87b56dd146103b1575f5ffd5b80638da5cb5b116100ce5780638da5cb5b1461033357806395d89b41146103445780639e8a1e7e1461034c578063a22cb4651461036c575f5ffd5b806370d4d9fd146102ee578063715018a6146103185780637f5950bd14610320575f5ffd5b806318160ddd1161015e5780635cefc90b116101395780635cefc90b1461028d5780635dce1ad8146102b55780636352211e146102c857806370a08231146102db575f5ffd5b806318160ddd1461025557806323b872dd1461026757806342842e0e1461027a575f5ffd5b8062ca4f78146101a457806301ffc9a7146101cc57806306fdde03146101df578063081812fc146101f4578063095ea7b31461021f5780630d8e6e2c14610234575b5f5ffd5b6101b76101b2366004611d5f565b610430565b60405190151581526020015b60405180910390f35b6101b76101da366004611db7565b6104d0565b6101e76104e0565b6040516101c39190611e00565b610207610202366004611e12565b61056f565b6040516001600160a01b0390911681526020016101c3565b61023261022d366004611e44565b610596565b005b6040805180820190915260058152640322e302e360dc1b60208201526101e7565b6008545b6040519081526020016101c3565b610232610275366004611e6c565b6105a5565b610232610288366004611e6c565b61062e565b6102a061029b366004611e12565b61064d565b604080519283526020830191909152016101c3565b6102596102c3366004611ea6565b610890565b6102076102d6366004611e12565b6108c2565b6102596102e9366004611ee7565b6108cc565b6103016102fc366004611ea6565b61093e565b6040805192151583526020830191909152016101c3565b610232610967565b61025961032e366004611f00565b61097a565b6007546001600160a01b0316610207565b6101e7610c5e565b61035f61035a366004611fbe565b610c6d565b6040516101c39190611fef565b61023261037a366004612031565b610e15565b61025961038d366004611e12565b600a6020525f908152604090205481565b6102326103ac36600461206a565b610e20565b6101e76103bf366004611e12565b610e38565b6103d76103d2366004611e12565b610e43565b6040516101c397969594939291906120e0565b6101b76103f8366004612148565b611019565b61023261040b366004611ee7565b611046565b61042361041e366004611e12565b611083565b6040516101c39190612179565b5f828152600260205260408120546001600160a01b031661046c5760405162461bcd60e51b81526004016104639061220d565b60405180910390fd5b8160405160200161047d9190612252565b60408051601f1981840301815282825280516020918201205f878152600983529290922091926104b1926001019101612295565b6040516020818303038152906040528051906020012014905092915050565b5f6104da826112fa565b92915050565b60605f80546104ee9061225d565b80601f016020809104026020016040519081016040528092919081815260200182805461051a9061225d565b80156105655780601f1061053c57610100808354040283529160200191610565565b820191905f5260205f20905b81548152906001019060200180831161054857829003601f168201915b5050505050905090565b5f6105798261131e565b505f828152600460205260409020546001600160a01b03166104da565b6105a1828233611356565b5050565b6001600160a01b0382166105ce57604051633250574960e11b81525f6004820152602401610463565b5f6105da838333611363565b9050836001600160a01b0316816001600160a01b031614610628576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610463565b50505050565b61064883838360405180602001604052805f815250610e20565b505050565b5f8181526002602052604081205481906001600160a01b03166106825760405162461bcd60e51b81526004016104639061220d565b5f83815260096020526040808220815160e081019092528054829082906106a89061225d565b80601f01602080910402602001604051908101604052809291908181526020018280546106d49061225d565b801561071f5780601f106106f65761010080835404028352916020019161071f565b820191905f5260205f20905b81548152906001019060200180831161070257829003601f168201915b505050505081526020016001820180546107389061225d565b80601f01602080910402602001604051908101604052809291908181526020018280546107649061225d565b80156107af5780601f10610786576101008083540402835291602001916107af565b820191905f5260205f20905b81548152906001019060200180831161079257829003601f168201915b505050505081526020016002820180546107c89061225d565b80601f01602080910402602001604051908101604052809291908181526020018280546107f49061225d565b801561083f5780601f106108165761010080835404028352916020019161083f565b820191905f5260205f20905b81548152906001019060200180831161082257829003601f168201915b505050918352505060038201546001600160a01b03166020820152600482015460408201526005820154606082015260069091015460809091015260c081015160a090910151909590945092505050565b5f82826040516020016108a4929190612306565b60405160208183030381529060405280519060200120905092915050565b5f6104da8261131e565b5f6001600160a01b0382166109355760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610463565b6104da82611455565b5f5f5f61094b8585610890565b5f908152600a6020526040902054801515969095509350505050565b61096f61149a565b6109785f6114c7565b565b5f5f8651116109cb5760405162461bcd60e51b815260206004820152601960248201527f46696c65206e616d652063616e6e6f7420626520656d707479000000000000006044820152606401610463565b5f855111610a1b5760405162461bcd60e51b815260206004820181905260248201527f4d65726b6c6520726f6f7420686173682063616e6e6f7420626520656d7074796044820152606401610463565b5f8411610a7c5760405162461bcd60e51b815260206004820152602960248201527f4372656174696f6e2074696d657374616d70206d75737420626520677265617460448201526806572207468616e20360bc1b6064820152608401610463565b5f610a878686610890565b5f818152600a602052604090205490915015610b0b5760405162461bcd60e51b815260206004820152603a60248201527f5a49502066696c652077697468207468697320636f6e74656e7420616e64207460448201527f696d657374616d7020616c726561647920746f6b656e697a65640000000000006064820152608401610463565b60088054905f610b1a8361231e565b9091555050600854610b2c3382611518565b835115610b3d57610b3d8185611531565b6040805160e08101825289815260208082018a9052818301889052336060830152608082018990524260a08301524360c08301525f84815260099091529190912081518190610b8c9082612386565b5060208201516001820190610ba19082612386565b5060408201516002820190610bb69082612386565b5060608201516003820180546001600160a01b0319166001600160a01b039092169190911790556080820151600482015560a0820151600582015560c0909101516006909101555f828152600a60205260409081902082905551339082907f0f09874b9c74d4595582d6c98e63000a1e9b6d57d383f3faa9b82ec744bc2db190610c4b908c908c908c908c9042904390612440565b60405180910390a3979650505050505050565b6060600180546104ee9061225d565b60605f6008546001600160401b03811115610c8a57610c8a611cb8565b604051908082528060200260200182016040528015610cb3578160200160208202803683370190505b5090505f60015b6008548111610d7d575f818152600260205260409020546001600160a01b031615610d6b5784604051602001610cf09190612252565b60408051601f1981840301815282825280516020918201205f85815260098352929092209192610d24926001019101612295565b6040516020818303038152906040528051906020012003610d6b5780838381518110610d5257610d52612494565b602090810291909101015281610d678161231e565b9250505b80610d758161231e565b915050610cba565b505f816001600160401b03811115610d9757610d97611cb8565b604051908082528060200260200182016040528015610dc0578160200160208202803683370190505b5090505f5b82811015610e0c57838181518110610ddf57610ddf612494565b6020026020010151828281518110610df957610df9612494565b6020908102919091010152600101610dc5565b50949350505050565b6105a1338383611580565b610e2b8484846105a5565b610628338585858561161e565b60606104da82611746565b60096020525f9081526040902080548190610e5d9061225d565b80601f0160208091040260200160405190810160405280929190818152602001828054610e899061225d565b8015610ed45780601f10610eab57610100808354040283529160200191610ed4565b820191905f5260205f20905b815481529060010190602001808311610eb757829003601f168201915b505050505090806001018054610ee99061225d565b80601f0160208091040260200160405190810160405280929190818152602001828054610f159061225d565b8015610f605780601f10610f3757610100808354040283529160200191610f60565b820191905f5260205f20905b815481529060010190602001808311610f4357829003601f168201915b505050505090806002018054610f759061225d565b80601f0160208091040260200160405190810160405280929190818152602001828054610fa19061225d565b8015610fec5780601f10610fc357610100808354040283529160200191610fec565b820191905f5260205f20905b815481529060010190602001808311610fcf57829003601f168201915b5050505060038301546004840154600585015460069095015493946001600160a01b039092169390925087565b6001600160a01b039182165f90815260056020908152604080832093909416825291909152205460ff1690565b61104e61149a565b6001600160a01b03811661107757604051631e4fbdf760e01b81525f6004820152602401610463565b611080816114c7565b50565b6110c86040518060e001604052806060815260200160608152602001606081526020015f6001600160a01b031681526020015f81526020015f81526020015f81525090565b5f828152600260205260409020546001600160a01b03166110fb5760405162461bcd60e51b81526004016104639061220d565b5f8281526009602052604090819020815160e081019092528054829082906111229061225d565b80601f016020809104026020016040519081016040528092919081815260200182805461114e9061225d565b80156111995780601f1061117057610100808354040283529160200191611199565b820191905f5260205f20905b81548152906001019060200180831161117c57829003601f168201915b505050505081526020016001820180546111b29061225d565b80601f01602080910402602001604051908101604052809291908181526020018280546111de9061225d565b80156112295780601f1061120057610100808354040283529160200191611229565b820191905f5260205f20905b81548152906001019060200180831161120c57829003601f168201915b505050505081526020016002820180546112429061225d565b80601f016020809104026020016040519081016040528092919081815260200182805461126e9061225d565b80156112b95780601f10611290576101008083540402835291602001916112b9565b820191905f5260205f20905b81548152906001019060200180831161129c57829003601f168201915b505050918352505060038201546001600160a01b03166020820152600482015460408201526005820154606082015260069091015460809091015292915050565b5f6001600160e01b03198216632483248360e11b14806104da57506104da82611851565b5f818152600260205260408120546001600160a01b0316806104da57604051637e27328960e01b815260048101849052602401610463565b61064883838360016118a0565b5f828152600260205260408120546001600160a01b039081169083161561138f5761138f8184866119a4565b6001600160a01b038116156113c9576113aa5f855f5f6118a0565b6001600160a01b0381165f90815260036020526040902080545f190190555b6001600160a01b038516156113f7576001600160a01b0385165f908152600360205260409020805460010190555b5f8481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b5f6001600160a01b03821661147f576040516322718ad960e21b81525f6004820152602401610463565b506001600160a01b03165f9081526003602052604090205490565b6007546001600160a01b031633146109785760405163118cdaa760e01b8152336004820152602401610463565b600780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6105a1828260405180602001604052805f815250611a08565b5f8281526006602052604090206115488282612386565b506040518281527ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce79060200160405180910390a15050565b6001600160a01b0382166115b257604051630b61174360e31b81526001600160a01b0383166004820152602401610463565b6001600160a01b038381165f81815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b1561173f57604051630a85bd0160e11b81526001600160a01b0384169063150b7a02906116609088908890879087906004016124a8565b6020604051808303815f875af192505050801561169a575060408051601f3d908101601f19168201909252611697918101906124e4565b60015b611701573d8080156116c7576040519150601f19603f3d011682016040523d82523d5f602084013e6116cc565b606091505b5080515f036116f957604051633250574960e11b81526001600160a01b0385166004820152602401610463565b805160208201fd5b6001600160e01b03198116630a85bd0160e11b1461173d57604051633250574960e11b81526001600160a01b0385166004820152602401610463565b505b5050505050565b60606117518261131e565b505f828152600660205260408120805461176a9061225d565b80601f01602080910402602001604051908101604052809291908181526020018280546117969061225d565b80156117e15780601f106117b8576101008083540402835291602001916117e1565b820191905f5260205f20905b8154815290600101906020018083116117c457829003601f168201915b505050505090505f6117fd60408051602081019091525f815290565b905080515f0361180e575092915050565b8151156118405780826040516020016118289291906124ff565b60405160208183030381529060405292505050919050565b61184984611a1f565b949350505050565b5f6001600160e01b031982166380ac58cd60e01b148061188157506001600160e01b03198216635b5e139f60e01b145b806104da57506301ffc9a760e01b6001600160e01b03198316146104da565b80806118b457506001600160a01b03821615155b15611975575f6118c38461131e565b90506001600160a01b038316158015906118ef5750826001600160a01b0316816001600160a01b031614155b801561190257506119008184611019565b155b1561192b5760405163a9fbf51f60e01b81526001600160a01b0384166004820152602401610463565b81156119735783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50505f90815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b6119af838383611a90565b610648576001600160a01b0383166119dd57604051637e27328960e01b815260048101829052602401610463565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610463565b611a128383611af1565b610648335f85858561161e565b6060611a2a8261131e565b505f611a4060408051602081019091525f815290565b90505f815111611a5e5760405180602001604052805f815250611a89565b80611a6884611b52565b604051602001611a799291906124ff565b6040516020818303038152906040525b9392505050565b5f6001600160a01b038316158015906118495750826001600160a01b0316846001600160a01b03161480611ac95750611ac98484611019565b806118495750505f908152600460205260409020546001600160a01b03908116911614919050565b6001600160a01b038216611b1a57604051633250574960e11b81525f6004820152602401610463565b5f611b2683835f611363565b90506001600160a01b03811615610648576040516339e3563760e11b81525f6004820152602401610463565b60605f611b5e83611be1565b60010190505f816001600160401b03811115611b7c57611b7c611cb8565b6040519080825280601f01601f191660200182016040528015611ba6576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611bb057509392505050565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b8310611c1f5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611c4b576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611c6957662386f26fc10000830492506010015b6305f5e1008310611c81576305f5e100830492506008015b6127108310611c9557612710830492506004015b60648310611ca7576064830492506002015b600a83106104da5760010192915050565b634e487b7160e01b5f52604160045260245ffd5b5f5f6001600160401b03841115611ce557611ce5611cb8565b50604051601f19601f85018116603f011681018181106001600160401b0382111715611d1357611d13611cb8565b604052838152905080828401851015611d2a575f5ffd5b838360208301375f60208583010152509392505050565b5f82601f830112611d50575f5ffd5b611a8983833560208501611ccc565b5f5f60408385031215611d70575f5ffd5b8235915060208301356001600160401b03811115611d8c575f5ffd5b611d9885828601611d41565b9150509250929050565b6001600160e01b031981168114611080575f5ffd5b5f60208284031215611dc7575f5ffd5b8135611a8981611da2565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f611a896020830184611dd2565b5f60208284031215611e22575f5ffd5b5035919050565b80356001600160a01b0381168114611e3f575f5ffd5b919050565b5f5f60408385031215611e55575f5ffd5b611e5e83611e29565b946020939093013593505050565b5f5f5f60608486031215611e7e575f5ffd5b611e8784611e29565b9250611e9560208501611e29565b929592945050506040919091013590565b5f5f60408385031215611eb7575f5ffd5b82356001600160401b03811115611ecc575f5ffd5b611ed885828601611d41565b95602094909401359450505050565b5f60208284031215611ef7575f5ffd5b611a8982611e29565b5f5f5f5f5f60a08688031215611f14575f5ffd5b85356001600160401b03811115611f29575f5ffd5b611f3588828901611d41565b95505060208601356001600160401b03811115611f50575f5ffd5b611f5c88828901611d41565b9450506040860135925060608601356001600160401b03811115611f7e575f5ffd5b611f8a88828901611d41565b92505060808601356001600160401b03811115611fa5575f5ffd5b611fb188828901611d41565b9150509295509295909350565b5f60208284031215611fce575f5ffd5b81356001600160401b03811115611fe3575f5ffd5b61184984828501611d41565b602080825282518282018190525f918401906040840190835b81811015612026578351835260209384019390920191600101612008565b509095945050505050565b5f5f60408385031215612042575f5ffd5b61204b83611e29565b91506020830135801515811461205f575f5ffd5b809150509250929050565b5f5f5f5f6080858703121561207d575f5ffd5b61208685611e29565b935061209460208601611e29565b92506040850135915060608501356001600160401b038111156120b5575f5ffd5b8501601f810187136120c5575f5ffd5b6120d487823560208401611ccc565b91505092959194509250565b60e081525f6120f260e083018a611dd2565b8281036020840152612104818a611dd2565b905082810360408401526121188189611dd2565b6001600160a01b039790971660608401525050608081019390935260a083019190915260c0909101529392505050565b5f5f60408385031215612159575f5ffd5b61216283611e29565b915061217060208401611e29565b90509250929050565b602081525f825160e06020840152612195610100840182611dd2565b90506020840151601f198483030160408501526121b28282611dd2565b9150506040840151601f198483030160608501526121d08282611dd2565b91505060018060a01b036060850151166080840152608084015160a084015260a084015160c084015260c084015160e08401528091505092915050565b602080825260149082015273151bdad95b88191bd95cc81b9bdd08195e1a5cdd60621b604082015260600190565b5f81518060208401855e5f93019283525090919050565b5f611a89828461223b565b600181811c9082168061227157607f821691505b60208210810361228f57634e487b7160e01b5f52602260045260245ffd5b50919050565b5f5f83546122a28161225d565b6001821680156122b957600181146122ce576122fb565b60ff19831686528115158202860193506122fb565b865f5260205f205f5b838110156122f3578154888201526001909101906020016122d7565b505081860193505b509195945050505050565b5f612311828561223b565b9283525050602001919050565b5f6001820161233b57634e487b7160e01b5f52601160045260245ffd5b5060010190565b601f82111561064857805f5260205f20601f840160051c810160208510156123675750805b601f840160051c820191505b8181101561173f575f8155600101612373565b81516001600160401b0381111561239f5761239f611cb8565b6123b3816123ad845461225d565b84612342565b6020601f8211600181146123e5575f83156123ce5750848201515b5f19600385901b1c1916600184901b17845561173f565b5f84815260208120601f198516915b8281101561241457878501518255602094850194600190920191016123f4565b508482101561243157868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b60c081525f61245260c0830189611dd2565b82810360208401526124648189611dd2565b9050866040840152828103606084015261247e8187611dd2565b6080840195909552505060a00152949350505050565b634e487b7160e01b5f52603260045260245ffd5b6001600160a01b03858116825284166020820152604081018390526080606082018190525f906124da90830184611dd2565b9695505050505050565b5f602082840312156124f4575f5ffd5b8151611a8981611da2565b5f61184961250d838661223b565b8461223b56fea2646970667358221220ec5692f96d1d270dc9c2c061988393c84d97f92e3bcc623597bccbb57a29d12d64736f6c634300081e0033
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Contract Compilation Helper for NZIP
|
|
5
|
+
*
|
|
6
|
+
* This script helps compile the NZIP-NFT.sol contract
|
|
7
|
+
* Usage: node compile-contract.js
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
|
|
13
|
+
const readline = require('readline');
|
|
14
|
+
|
|
15
|
+
const rl = readline.createInterface({
|
|
16
|
+
input: process.stdin,
|
|
17
|
+
output: process.stdout
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
console.log('š§ NZIP Contract Compilation Helper');
|
|
21
|
+
console.log('===================================\n');
|
|
22
|
+
|
|
23
|
+
const contractPath = path.join(__dirname, 'src/NZIP-NFT.sol');
|
|
24
|
+
const deployPath = path.join(__dirname, 'deploy/deploy-public-contract.js');
|
|
25
|
+
|
|
26
|
+
if (!fs.existsSync(contractPath)) {
|
|
27
|
+
console.log('ā Contract file not found:', contractPath);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log('š Choose your compilation method:\n');
|
|
32
|
+
console.log('1ļøā£ Remix IDE (Online) - RECOMMENDED');
|
|
33
|
+
console.log('2ļøā£ Remix IDE (Step-by-Step Guide) - NEW!');
|
|
34
|
+
console.log('3ļøā£ Local Hardhat (Advanced)');
|
|
35
|
+
console.log('4ļøā£ View Deprecated Contract Info');
|
|
36
|
+
console.log('5ļøā£ View Contract Source Code');
|
|
37
|
+
console.log('6ļøā£ Exit\n');
|
|
38
|
+
|
|
39
|
+
rl.question('Enter your choice (1-6): ', (choice) => {
|
|
40
|
+
console.log('');
|
|
41
|
+
|
|
42
|
+
switch(choice.trim()) {
|
|
43
|
+
case '1':
|
|
44
|
+
showRemixInstructions();
|
|
45
|
+
break;
|
|
46
|
+
case '2':
|
|
47
|
+
showRemixGuide();
|
|
48
|
+
break;
|
|
49
|
+
case '3':
|
|
50
|
+
showHardhatInstructions();
|
|
51
|
+
break;
|
|
52
|
+
case '4':
|
|
53
|
+
showDeprecatedInfo();
|
|
54
|
+
break;
|
|
55
|
+
case '5':
|
|
56
|
+
showContractSource();
|
|
57
|
+
break;
|
|
58
|
+
case '6':
|
|
59
|
+
console.log('š Goodbye!');
|
|
60
|
+
rl.close();
|
|
61
|
+
return;
|
|
62
|
+
default:
|
|
63
|
+
console.log('ā Invalid choice. Please run the script again and choose 1-6.');
|
|
64
|
+
rl.close();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
rl.close();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
function showRemixInstructions() {
|
|
72
|
+
console.log('š Remix IDE Compilation (RECOMMENDED)');
|
|
73
|
+
console.log('======================================\n');
|
|
74
|
+
console.log('š Steps:');
|
|
75
|
+
console.log('1. Go to https://remix.ethereum.org');
|
|
76
|
+
console.log('2. Create new file: NZIP-NFT.sol');
|
|
77
|
+
console.log('3. Copy contract content (run with option 5 to see source)');
|
|
78
|
+
console.log('4. Install OpenZeppelin dependencies');
|
|
79
|
+
console.log('5. Compile with Solidity 0.8.19+');
|
|
80
|
+
console.log('6. Copy bytecode and ABI from compilation artifacts');
|
|
81
|
+
console.log('7. Update deployment script with compiled data\n');
|
|
82
|
+
|
|
83
|
+
console.log('šÆ After compilation:');
|
|
84
|
+
console.log('⢠Update CONTRACT_BYTECODE in deploy-public-contract.js');
|
|
85
|
+
console.log('⢠Update CONTRACT_ABI in deploy-public-contract.js');
|
|
86
|
+
console.log('⢠Run: npm run deploy:public');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function showRemixGuide() {
|
|
90
|
+
console.log('š Remix IDE Step-by-Step Guide');
|
|
91
|
+
console.log('===============================\n');
|
|
92
|
+
console.log('For a detailed, interactive walkthrough of the entire Remix compilation process:');
|
|
93
|
+
console.log('');
|
|
94
|
+
console.log('šÆ Run this command:');
|
|
95
|
+
console.log('npm run remix-compile\n');
|
|
96
|
+
|
|
97
|
+
console.log('⨠This dedicated guide will:');
|
|
98
|
+
console.log('⢠Walk you through each step interactively');
|
|
99
|
+
console.log('⢠Show you exactly what to do in Remix');
|
|
100
|
+
console.log('⢠Display the contract source when needed');
|
|
101
|
+
console.log('⢠Guide you through extracting bytecode and ABI');
|
|
102
|
+
console.log('⢠Help you update the deployment script');
|
|
103
|
+
console.log('⢠Prepare you for deployment\n');
|
|
104
|
+
|
|
105
|
+
console.log('š” Perfect for first-time users or when you need detailed guidance!');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function showHardhatInstructions() {
|
|
109
|
+
console.log('š» Local Hardhat Compilation (Advanced)');
|
|
110
|
+
console.log('=======================================\n');
|
|
111
|
+
console.log('š Setup Steps:');
|
|
112
|
+
console.log('1. npm install --save-dev hardhat @nomiclabs/hardhat-ethers ethers @openzeppelin/contracts');
|
|
113
|
+
console.log('2. npx hardhat init');
|
|
114
|
+
console.log('3. Copy contract to contracts/ folder');
|
|
115
|
+
console.log('4. npx hardhat compile');
|
|
116
|
+
console.log('5. Extract bytecode and ABI from artifacts/\n');
|
|
117
|
+
|
|
118
|
+
console.log('š Artifact Location:');
|
|
119
|
+
console.log('⢠Bytecode: artifacts/contracts/NZIP-NFT.sol/ZipFileNFT.json');
|
|
120
|
+
console.log('⢠Look for "bytecode" and "abi" fields in the JSON file\n');
|
|
121
|
+
|
|
122
|
+
console.log('šÆ After compilation:');
|
|
123
|
+
console.log('⢠Update CONTRACT_BYTECODE in deploy-public-contract.js');
|
|
124
|
+
console.log('⢠Update CONTRACT_ABI in deploy-public-contract.js');
|
|
125
|
+
console.log('⢠Run: npm run deploy:public');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function showDeprecatedInfo() {
|
|
129
|
+
console.log('ā ļø Deprecated Contract Notice');
|
|
130
|
+
console.log('=============================\n');
|
|
131
|
+
console.log('Previous contract is now DEPRECATED:');
|
|
132
|
+
console.log('Address: 0xb78CB3bcC788fca38c731b1E9D70CF60b04CA015');
|
|
133
|
+
console.log('Network: Base Sepolia');
|
|
134
|
+
console.log('Status: ā DEPRECATED - Do not use\n');
|
|
135
|
+
|
|
136
|
+
console.log('šØ Why it\'s deprecated:');
|
|
137
|
+
console.log('⢠Had broken block hash storage (always returned 0)');
|
|
138
|
+
console.log('⢠Missing input validation');
|
|
139
|
+
console.log('⢠Lacked proper version tracking\n');
|
|
140
|
+
|
|
141
|
+
console.log('ā
New contract fixes:');
|
|
142
|
+
console.log('⢠Removed unreliable block hash storage');
|
|
143
|
+
console.log('⢠Added comprehensive input validation');
|
|
144
|
+
console.log('⢠Version 2.0 with proper documentation');
|
|
145
|
+
console.log('⢠Improved error handling\n');
|
|
146
|
+
|
|
147
|
+
console.log('š Action Required:');
|
|
148
|
+
console.log('You MUST compile and deploy a new contract!');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function showContractSource() {
|
|
152
|
+
console.log('š NZIP NFT Contract v2.0 Source Code');
|
|
153
|
+
console.log('=====================================\n');
|
|
154
|
+
console.log('Copy this code to your compilation environment:\n');
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
const contractContent = fs.readFileSync(contractPath, 'utf8');
|
|
158
|
+
console.log(contractContent);
|
|
159
|
+
} catch (err) {
|
|
160
|
+
console.log('ā Error reading contract:', err.message);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
console.log('\nšÆ Next Steps:');
|
|
164
|
+
console.log('1. Copy the contract code above');
|
|
165
|
+
console.log('2. Use Remix IDE or Hardhat to compile');
|
|
166
|
+
console.log('3. Update deployment script with compiled bytecode/ABI');
|
|
167
|
+
console.log('4. Deploy with: npm run deploy:public');
|
|
168
|
+
}
|