neozipkit 0.1.1 → 0.2.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 +52 -105
- package/contracts/INTEGRATION.md +338 -0
- package/contracts/NETWORKS.md +156 -0
- package/contracts/README.md +152 -0
- package/{src/server/blockchain → contracts}/constants.ts +5 -22
- package/contracts/deploy-bytecode.mjs +94 -0
- package/dist/blockchain/ZipKitMinter.d.ts +106 -0
- package/dist/blockchain/ZipKitMinter.js +347 -0
- package/dist/blockchain/ZipKitNFT.d.ts +3 -0
- package/dist/blockchain/ZipKitNFT.js +7 -0
- package/dist/blockchain/ZipKitOTS.d.ts +135 -0
- package/dist/blockchain/ZipKitOTS.js +564 -0
- package/dist/blockchain/ZipKitVerifier.d.ts +69 -0
- package/dist/blockchain/ZipKitVerifier.js +289 -0
- package/dist/{server/blockchain/WalletAnalyzer.d.ts → blockchain/ZipKitWallet.d.ts} +31 -43
- package/dist/{server/blockchain/WalletAnalyzer.js → blockchain/ZipKitWallet.js} +193 -161
- package/dist/blockchain/contracts.d.ts +14 -0
- package/dist/blockchain/contracts.js +77 -0
- package/dist/blockchain/index.d.ts +7 -0
- package/dist/blockchain/index.js +50 -0
- package/dist/{server/blockchain → blockchain}/types.d.ts +12 -34
- package/dist/{server/blockchain → blockchain}/types.js +1 -22
- package/dist/browser-index.d.ts +0 -3
- package/dist/browser-index.js +4 -5
- package/dist/browser.d.ts +0 -3
- package/dist/browser.js +4 -5
- package/dist/index.d.ts +8 -15
- package/dist/index.js +12 -24
- package/dist/server/{platform/server/ZipKitServer.d.ts → ZipKitServer.d.ts} +4 -35
- package/dist/server/{platform/server/ZipKitServer.js → ZipKitServer.js} +55 -182
- package/dist/shared/ZipEntry.js +1 -1
- package/dist/shared/ZipKit.d.ts +0 -6
- package/dist/shared/ZipKit.js +1 -18
- package/dist/shared/types.js +2 -2
- package/dist/shared/version.d.ts +2 -4
- package/dist/shared/version.js +4 -5
- package/package.json +13 -3
- package/src/blockchain/README.md +229 -0
- package/src/blockchain/ZipKitMinter.ts +470 -0
- package/src/blockchain/ZipKitNFT.ts +12 -0
- package/src/blockchain/ZipKitOTS.ts +622 -0
- package/src/blockchain/ZipKitVerifier.ts +382 -0
- package/src/blockchain/ZipKitWallet.ts +338 -0
- package/src/blockchain/contracts.ts +88 -0
- package/src/blockchain/index.ts +61 -0
- package/src/blockchain/types.ts +91 -0
- package/src/browser/{TokenVerifierBrowser.ts → TokenVerifierBrowser.ts-remove} +1 -1
- package/src/browser-index.ts +3 -3
- package/src/index.ts +10 -17
- package/src/server/README.md +25 -0
- package/src/server/ZipKitServer.ts +305 -0
- package/src/shared/ZipEntry.ts +1 -1
- package/src/shared/ZipKit.ts +1 -19
- package/src/shared/types.ts +3 -3
- package/src/shared/version.ts +3 -4
- package/src/types/modules.d.ts +11 -1
- package/contracts/Lock.sol +0 -34
- package/contracts/compile-contract.js +0 -168
- package/contracts/deploy/deploy-both-contracts.js +0 -286
- package/contracts/deploy/deploy-enhanced-contract.js +0 -197
- package/contracts/deploy/deploy-private-contract.js +0 -190
- package/contracts/deploy/deploy-public-clean.js +0 -1063
- package/contracts/deploy/deploy-public-contract.js +0 -1107
- package/contracts/deployment.config.example.js +0 -25
- package/contracts/remix-compile.js +0 -222
- package/contracts/setup-deployment.js +0 -51
- package/contracts/src/ZipFileNFT-DEPRECATED-6field.sol +0 -260
- package/contracts/src/ZipFileNFT-DEPRECATED-Enhanced.sol +0 -289
- package/dist/browser/CertificateGeneratorBrowser.d.ts +0 -75
- package/dist/browser/CertificateGeneratorBrowser.js +0 -433
- package/dist/browser/TokenVerifierBrowser.d.ts +0 -76
- package/dist/browser/TokenVerifierBrowser.js +0 -299
- package/dist/server/blockchain/NFTMinter.d.ts +0 -41
- package/dist/server/blockchain/NFTMinter.js +0 -323
- package/dist/server/blockchain/TokenQuerier.d.ts +0 -31
- package/dist/server/blockchain/TokenQuerier.js +0 -259
- package/dist/server/blockchain/TokenVerifier.d.ts +0 -20
- package/dist/server/blockchain/TokenVerifier.js +0 -395
- package/dist/server/blockchain/WalletFormatter.d.ts +0 -39
- package/dist/server/blockchain/WalletFormatter.js +0 -196
- package/dist/server/blockchain/WalletManager.d.ts +0 -46
- package/dist/server/blockchain/WalletManager.js +0 -294
- package/dist/server/blockchain/ZipMetadata.d.ts +0 -27
- package/dist/server/blockchain/ZipMetadata.js +0 -131
- package/dist/server/blockchain/ZipTokenProcessor.d.ts +0 -44
- package/dist/server/blockchain/ZipTokenProcessor.js +0 -204
- package/dist/server/blockchain/constants.d.ts +0 -102
- package/dist/server/blockchain/constants.js +0 -968
- package/dist/server/blockchain/index.d.ts +0 -9
- package/dist/server/blockchain/index.js +0 -44
- package/dist/server/blockchain/test-certificate.d.ts +0 -8
- package/dist/server/blockchain/test-certificate.js +0 -100
- package/dist/server/platform/servercomponents/ZipKitOTS.d.ts +0 -91
- package/dist/server/platform/servercomponents/ZipKitOTS.js +0 -271
- package/examples/unzip-token.ts +0 -488
- package/examples/zip-token.ts +0 -604
- package/src/server/blockchain/NFTMinter.ts +0 -357
- package/src/server/blockchain/TokenQuerier.ts +0 -287
- package/src/server/blockchain/TokenVerifier.ts +0 -453
- package/src/server/blockchain/WalletAnalyzer.ts +0 -397
- package/src/server/blockchain/WalletFormatter.ts +0 -206
- package/src/server/blockchain/WalletManager.ts +0 -294
- package/src/server/blockchain/ZipMetadata.ts +0 -117
- package/src/server/blockchain/ZipTokenProcessor.ts +0 -234
- package/src/server/blockchain/index.ts +0 -42
- package/src/server/blockchain/test-certificate.ts +0 -137
- package/src/server/blockchain/types.ts +0 -134
- package/src/server/platform/server/ZipKitServer.ts +0 -459
- package/src/server/platform/servercomponents/ZipKitOTS.ts +0 -313
- package/src/server/platform/servercomponents/opentimestamps.d.ts +0 -23
- /package/contracts/{bytecode.txt → NZIP-NFT-bytecode.txt} +0 -0
- /package/dist/{server/blockchain → blockchain}/CertificateToken.d.ts +0 -0
- /package/dist/{server/blockchain → blockchain}/CertificateToken.js +0 -0
- /package/src/{server/blockchain → blockchain}/CertificateToken.ts +0 -0
- /package/src/browser/{CertificateGeneratorBrowser.ts → CertificateGeneratorBrowser.ts-remove} +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# NeoZipKit Smart Contracts
|
|
2
|
+
|
|
3
|
+
This directory contains production-ready smart contracts for ZIP file tokenization and their deployment utilities.
|
|
4
|
+
|
|
5
|
+
## 🎯 Contract Types
|
|
6
|
+
|
|
7
|
+
### 🌐 Main Contract (`NZIP-NFT.sol`)
|
|
8
|
+
- **Universal verification** - Anyone can verify any token
|
|
9
|
+
- **Public blockchain metadata** - All data visible on blockchain
|
|
10
|
+
- **Use cases**: Certificates, public records, open-source projects, general tokenization
|
|
11
|
+
- **Symbol**: `NZIP`
|
|
12
|
+
|
|
13
|
+
## 📍 Current Deployment
|
|
14
|
+
|
|
15
|
+
**✅ Production Contract (v2.0)**:
|
|
16
|
+
```
|
|
17
|
+
Address: 0xFD76a5d420704F34d84b0767961835c43D7b30a8
|
|
18
|
+
Network: Base Sepolia
|
|
19
|
+
Version: 2.0.0
|
|
20
|
+
Status: ✅ ACTIVE - Use for all new integrations
|
|
21
|
+
Explorer: https://sepolia.basescan.org/address/0xFD76a5d420704F34d84b0767961835c43D7b30a8
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 🔧 Supported Features
|
|
25
|
+
|
|
26
|
+
- **NFT Tokenization**: Convert ZIP files into ERC-721 NFTs with complete metadata
|
|
27
|
+
- **Blockchain Verification**: Verify ZIP file authenticity against blockchain tokens
|
|
28
|
+
- **OpenTimestamps**: Bitcoin blockchain timestamping for file integrity
|
|
29
|
+
- **Multi-Network Support**: Base Mainnet, Base Sepolia, Ethereum, Polygon, Arbitrum
|
|
30
|
+
- **Smart Contracts**: Production-ready contracts for public and private tokenization
|
|
31
|
+
|
|
32
|
+
## 🏗️ Blockchain Components
|
|
33
|
+
|
|
34
|
+
- **`TokenVerifier`** - Verify tokenized ZIP files against blockchain
|
|
35
|
+
- **`NFTMinter`** - Mint NFTs for ZIP files
|
|
36
|
+
- **`TokenQuerier`** - Query token information from blockchain
|
|
37
|
+
- **`CertificateToken`** - Generate certificates for tokenized files
|
|
38
|
+
- **`ZipTokenProcessor`** - Process ZIP files for tokenization
|
|
39
|
+
- **`WalletManager`** - Manage wallet connections and networks
|
|
40
|
+
|
|
41
|
+
## 📁 Directory Structure
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
contracts/
|
|
45
|
+
├── src/ # Smart contract source files
|
|
46
|
+
│ ├── NZIP-NFT.sol # Main tokenization contract
|
|
47
|
+
│ ├── NZIP-NFT-Private.sol # Private tokenization contract
|
|
48
|
+
│ └── *.sol # Legacy and deprecated contracts
|
|
49
|
+
├── constants.ts # Contract addresses and deployment info
|
|
50
|
+
└── *.md # Documentation files
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 🚀 Quick Start
|
|
54
|
+
|
|
55
|
+
1. **Deploy contract using Remix IDE**:
|
|
56
|
+
- Open [Remix IDE](https://remix.ethereum.org/)
|
|
57
|
+
- Upload contract files from `src/` directory
|
|
58
|
+
- Compile and deploy using Remix
|
|
59
|
+
|
|
60
|
+
2. **Integrate with your application**:
|
|
61
|
+
```typescript
|
|
62
|
+
import { ZipTokenProcessor, MintingOptions } from 'neozipkit/server/blockchain';
|
|
63
|
+
|
|
64
|
+
const options: MintingOptions = {
|
|
65
|
+
wallet: 'path/to/wallet.json',
|
|
66
|
+
network: 'base-sepolia',
|
|
67
|
+
mintToken: true
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const processor = new ZipTokenProcessor('archive.zip', 'merkle_root_hash', options);
|
|
71
|
+
const result = await processor.processZipToken(options);
|
|
72
|
+
|
|
73
|
+
if (result.error) {
|
|
74
|
+
console.error('Processing failed:', result.error);
|
|
75
|
+
} else {
|
|
76
|
+
console.log('Success!', result);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
3. **Command-line deployment scripts**
|
|
80
|
+
|
|
81
|
+
- Base Mainnet
|
|
82
|
+
```bash
|
|
83
|
+
cd /Users/stevenburg/Projects/NeoWare/neozipkit
|
|
84
|
+
export PRIVATE_KEY=0xYOUR_DEPLOYER_PRIVATE_KEY
|
|
85
|
+
export BASE_RPC_URL=https://mainnet.base.org
|
|
86
|
+
node contracts/deploy-bytecode.mjs
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- Base Sepolia
|
|
90
|
+
```bash
|
|
91
|
+
cd /Users/stevenburg/Projects/NeoWare/neozipkit
|
|
92
|
+
export PRIVATE_KEY=0xYOUR_DEPLOYER_PRIVATE_KEY
|
|
93
|
+
export NETWORK=base-sepolia
|
|
94
|
+
export BASE_RPC_URL=https://sepolia.base.org
|
|
95
|
+
node contracts/deploy-bytecode.mjs
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- Ethereum Mainnet
|
|
99
|
+
```bash
|
|
100
|
+
cd /Users/stevenburg/Projects/NeoWare/neozipkit
|
|
101
|
+
export PRIVATE_KEY=0xYOUR_DEPLOYER_PRIVATE_KEY
|
|
102
|
+
export NETWORK=eth
|
|
103
|
+
export ETH_RPC_URL=https://mainnet.infura.io/v3/YOUR_KEY
|
|
104
|
+
node contracts/deploy-bytecode.mjs
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 📦 Contract Constants and ABI
|
|
108
|
+
|
|
109
|
+
Contract addresses and deployment info are in `contracts/constants.ts`, while the ABI is in `src/blockchain/abi.ts`.
|
|
110
|
+
|
|
111
|
+
**Contract Constants** (`contracts/constants.ts`):
|
|
112
|
+
- `CONTRACT_ADDRESSES`: ChainId → address map (`NZIP_NFT` group)
|
|
113
|
+
- `DEPRECATED_CONTRACTS`: Historical addresses
|
|
114
|
+
- `CURRENT_DEPLOYMENT`: Current network, chainId, address, and tx/explorer info
|
|
115
|
+
|
|
116
|
+
**Contract ABI** (`src/blockchain/abi.ts`):
|
|
117
|
+
- `NZIP_CONTRACT_ABI`: Full contract ABI for integration
|
|
118
|
+
|
|
119
|
+
Example usage:
|
|
120
|
+
```ts
|
|
121
|
+
// For deployment scripts and contract management
|
|
122
|
+
import { CONTRACT_ADDRESSES, CURRENT_DEPLOYMENT } from '../contracts/constants';
|
|
123
|
+
|
|
124
|
+
// For application integration
|
|
125
|
+
import { NZIP_CONTRACT_ABI } from 'neozipkit/blockchain/abi';
|
|
126
|
+
import { CONTRACT_ADDRESSES } from 'neozipkit/blockchain/constants';
|
|
127
|
+
|
|
128
|
+
const baseSepolia = CONTRACT_ADDRESSES.NZIP_NFT[84532];
|
|
129
|
+
console.log('Base Sepolia NZIP‑NFT:', baseSepolia);
|
|
130
|
+
console.log('ABI functions:', NZIP_CONTRACT_ABI.map((f: any) => f.name).filter(Boolean));
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 🔐 Security Considerations
|
|
134
|
+
|
|
135
|
+
### Development Best Practices
|
|
136
|
+
|
|
137
|
+
- **Private Keys**: Never commit private keys or mnemonics to version control
|
|
138
|
+
- **Network Security**: Use secure RPC endpoints and validate all inputs
|
|
139
|
+
- **Smart Contract Audits**: Audit contracts before production deployment
|
|
140
|
+
- **Error Handling**: Implement comprehensive error handling for all operations
|
|
141
|
+
- **Type Safety**: Leverage TypeScript for compile-time error detection
|
|
142
|
+
|
|
143
|
+
### File Verification
|
|
144
|
+
|
|
145
|
+
- **Merkle Trees**: All ZIP files use cryptographic Merkle trees for integrity verification
|
|
146
|
+
- **Blockchain Anchoring**: Timestamps and hashes are anchored to blockchain networks
|
|
147
|
+
- **Multi-Layer Verification**: Support for both OpenTimestamps and NFT-based verification
|
|
148
|
+
|
|
149
|
+
## 📄 Additional Documentation
|
|
150
|
+
|
|
151
|
+
- **[Network Configuration](./NETWORKS.md)** - Supported networks and configuration
|
|
152
|
+
- **[Integration Guide](./INTEGRATION.md)** - How to integrate contracts with your application
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
export const CONTRACT_ADDRESSES = {
|
|
5
5
|
NZIP_NFT: {
|
|
6
6
|
84532: "0xFD76a5d420704F34d84b0767961835c43D7b30a8", // Current v2.0 contract
|
|
7
|
-
8453: "",
|
|
8
|
-
1: "", // Ethereum Mainnet
|
|
7
|
+
8453: "0x2716c4609fD97DaEdF429BC4B4Ec2faa81e2cC60", // Base Mainnet
|
|
8
|
+
1: "", // Ethereum Mainnet - set after deployment
|
|
9
9
|
11155111: "", // Sepolia Testnet
|
|
10
10
|
137: "", // Polygon
|
|
11
11
|
42161: "", // Arbitrum
|
|
@@ -936,25 +936,6 @@ export const NZIP_CONTRACT_ABI = [
|
|
|
936
936
|
}
|
|
937
937
|
];
|
|
938
938
|
|
|
939
|
-
/**
|
|
940
|
-
* Helper function to get contract address for a chain
|
|
941
|
-
*/
|
|
942
|
-
export function getNZipContractAddress(chainId: number): string {
|
|
943
|
-
return CONTRACT_ADDRESSES.NZIP_NFT[chainId] || "";
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
/**
|
|
947
|
-
* Network configurations
|
|
948
|
-
*/
|
|
949
|
-
export const NETWORK_CONFIG: Record<number, string> = {
|
|
950
|
-
1: "Ethereum Mainnet",
|
|
951
|
-
11155111: "Sepolia Testnet",
|
|
952
|
-
84532: "Base Sepolia",
|
|
953
|
-
8453: "Base Mainnet",
|
|
954
|
-
137: "Polygon",
|
|
955
|
-
42161: "Arbitrum",
|
|
956
|
-
};
|
|
957
|
-
|
|
958
939
|
/**
|
|
959
940
|
* Current deployment information
|
|
960
941
|
*/
|
|
@@ -966,4 +947,6 @@ export const CURRENT_DEPLOYMENT = {
|
|
|
966
947
|
deployedAt: "2024-11-29", // Update when deploying to new networks
|
|
967
948
|
txHash: "0x7f12a5974b6e6ee6cbb8bc6068b6d784fcc448a6fc567d1cc8a34b98a48efd9f",
|
|
968
949
|
explorer: "https://sepolia.basescan.org/address/0xFD76a5d420704F34d84b0767961835c43D7b30a8"
|
|
969
|
-
};
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// NZIP-NFT deployment script using precompiled bytecode
|
|
2
|
+
// Usage (Base Mainnet):
|
|
3
|
+
// env PRIVATE_KEY=0x... BASE_RPC_URL=https://mainnet.base.org node contracts/deploy-bytecode.mjs
|
|
4
|
+
// Usage (Base Sepolia):
|
|
5
|
+
// env PRIVATE_KEY=0x... NETWORK=base-sepolia BASE_RPC_URL=https://sepolia.base.org node contracts/deploy-bytecode.mjs
|
|
6
|
+
// Usage (Ethereum Mainnet):
|
|
7
|
+
// env PRIVATE_KEY=0x... NETWORK=eth ETH_RPC_URL=https://mainnet.infura.io/v3/<KEY> node contracts/deploy-bytecode.mjs
|
|
8
|
+
// Optional env:
|
|
9
|
+
// BYTECODE_PATH=contracts/NZIP-NFT-bytecode.txt
|
|
10
|
+
// NETWORK=base | base-sepolia | eth
|
|
11
|
+
|
|
12
|
+
import fs from 'node:fs';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
|
|
15
|
+
const { ethers } = await import('ethers');
|
|
16
|
+
|
|
17
|
+
const NETWORK = process.env.NETWORK || 'base';
|
|
18
|
+
const DEFAULT_RPCS = {
|
|
19
|
+
'base': 'https://mainnet.base.org',
|
|
20
|
+
'base-sepolia': 'https://sepolia.base.org',
|
|
21
|
+
'eth': 'https://eth.llamarpc.com',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const PRIVATE_KEY = process.env.PRIVATE_KEY;
|
|
25
|
+
// Prefer network-specific env var, then fall back to defaults
|
|
26
|
+
const RPC_URL = (
|
|
27
|
+
NETWORK === 'eth'
|
|
28
|
+
? process.env.ETH_RPC_URL
|
|
29
|
+
: process.env.BASE_RPC_URL
|
|
30
|
+
) || DEFAULT_RPCS[NETWORK] || DEFAULT_RPCS['base'];
|
|
31
|
+
const BYTECODE_PATH = process.env.BYTECODE_PATH || path.join(process.cwd(), 'contracts', 'NZIP-NFT-bytecode.txt');
|
|
32
|
+
|
|
33
|
+
if (!PRIVATE_KEY) {
|
|
34
|
+
console.error('Error: PRIVATE_KEY env var is required');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function loadBytecode(filePath) {
|
|
39
|
+
const raw = fs.readFileSync(filePath, 'utf8').trim();
|
|
40
|
+
if (!raw) throw new Error(`Empty bytecode in ${filePath}`);
|
|
41
|
+
return raw.startsWith('0x') ? raw : '0x' + raw;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function main() {
|
|
45
|
+
console.log(`Deploying NZIP-NFT bytecode to ${NETWORK} via ${RPC_URL}`);
|
|
46
|
+
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
|
47
|
+
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);
|
|
48
|
+
|
|
49
|
+
const bytecode = loadBytecode(BYTECODE_PATH);
|
|
50
|
+
|
|
51
|
+
const [nonce, balanceWei] = await Promise.all([
|
|
52
|
+
provider.getTransactionCount(wallet.address),
|
|
53
|
+
provider.getBalance(wallet.address),
|
|
54
|
+
]);
|
|
55
|
+
console.log('Deployer address:', wallet.address);
|
|
56
|
+
console.log('Deployer balance:', ethers.formatEther(balanceWei), 'ETH');
|
|
57
|
+
const fee = await provider.getFeeData();
|
|
58
|
+
const txReq = {
|
|
59
|
+
from: wallet.address,
|
|
60
|
+
data: bytecode,
|
|
61
|
+
// EIP-1559 fields if available
|
|
62
|
+
maxFeePerGas: fee.maxFeePerGas ?? undefined,
|
|
63
|
+
maxPriorityFeePerGas: fee.maxPriorityFeePerGas ?? undefined,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const gasLimit = await wallet.estimateGas(txReq).catch(() => null);
|
|
67
|
+
if (gasLimit) {
|
|
68
|
+
txReq.gasLimit = gasLimit;
|
|
69
|
+
console.log('Estimated gas limit:', gasLimit.toString());
|
|
70
|
+
} else {
|
|
71
|
+
console.log('Estimated gas limit: unavailable (provider failed to estimate)');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.log('Sending deployment tx...');
|
|
75
|
+
const tx = await wallet.sendTransaction(txReq);
|
|
76
|
+
console.log('Tx hash:', tx.hash);
|
|
77
|
+
const receipt = await tx.wait();
|
|
78
|
+
|
|
79
|
+
if (!receipt || !receipt.contractAddress) {
|
|
80
|
+
console.error('Deployment failed or contractAddress not returned. Receipt:', receipt);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log('Deployed contract address:', receipt.contractAddress);
|
|
85
|
+
console.log('Block number:', receipt.blockNumber);
|
|
86
|
+
console.log('NOTE: Update src/server/blockchain/constants.ts with this address for the corresponding chainId.');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main().catch((err) => {
|
|
90
|
+
console.error('Deployment error:', err);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ZipKitMinter - Handles NFT token minting for ZIP files
|
|
4
|
+
* Minter API for NZIP-NFT smart contract.
|
|
5
|
+
*/
|
|
6
|
+
import type { TokenMetadata } from './types';
|
|
7
|
+
export interface MintingOptions {
|
|
8
|
+
walletPrivateKey: string;
|
|
9
|
+
network: string;
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface MintingResult {
|
|
14
|
+
success: boolean;
|
|
15
|
+
message: string;
|
|
16
|
+
tokenId?: string;
|
|
17
|
+
transactionHash?: string;
|
|
18
|
+
contractAddress?: string;
|
|
19
|
+
blockNumber?: number;
|
|
20
|
+
walletAddress?: string;
|
|
21
|
+
gasUsed?: string;
|
|
22
|
+
gasCost?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TokenInfo {
|
|
25
|
+
tokenId: string;
|
|
26
|
+
owner: string;
|
|
27
|
+
isOwnedByUser: boolean;
|
|
28
|
+
tokenData?: any;
|
|
29
|
+
}
|
|
30
|
+
export interface DuplicateCheckResult {
|
|
31
|
+
hasExistingTokens: boolean;
|
|
32
|
+
allTokens: TokenInfo[];
|
|
33
|
+
userOwnedTokens: TokenInfo[];
|
|
34
|
+
othersTokens: TokenInfo[];
|
|
35
|
+
}
|
|
36
|
+
export interface WalletInfo {
|
|
37
|
+
address: string;
|
|
38
|
+
balance: string;
|
|
39
|
+
networkName: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Blockchain Token Minter for ZIP files
|
|
43
|
+
*/
|
|
44
|
+
export declare class ZipKitMinter {
|
|
45
|
+
private provider;
|
|
46
|
+
private wallet;
|
|
47
|
+
private contract;
|
|
48
|
+
private merkleRoot;
|
|
49
|
+
private archiveName;
|
|
50
|
+
private networkConfig;
|
|
51
|
+
private debug;
|
|
52
|
+
constructor(archiveName: string, merkleRoot: string, options: MintingOptions);
|
|
53
|
+
/**
|
|
54
|
+
* Get wallet information
|
|
55
|
+
*/
|
|
56
|
+
getWalletInfo(): Promise<WalletInfo>;
|
|
57
|
+
/**
|
|
58
|
+
* Check for existing tokens with same merkle root and verify ownership
|
|
59
|
+
*/
|
|
60
|
+
checkForDuplicates(): Promise<DuplicateCheckResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Estimate gas costs for minting
|
|
63
|
+
*/
|
|
64
|
+
estimateGasCosts(): Promise<{
|
|
65
|
+
gasLimit: bigint;
|
|
66
|
+
gasPrice: bigint;
|
|
67
|
+
estimatedCost: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Create token metadata string
|
|
71
|
+
*/
|
|
72
|
+
private createTokenMetadataString;
|
|
73
|
+
/**
|
|
74
|
+
* Create TokenMetadata object from minting result
|
|
75
|
+
*/
|
|
76
|
+
private createTokenMetadata;
|
|
77
|
+
/**
|
|
78
|
+
* Mint new token on blockchain
|
|
79
|
+
*/
|
|
80
|
+
mintToken(): Promise<MintingResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Main minting process - checks for duplicates, then mints if needed
|
|
83
|
+
*/
|
|
84
|
+
processMinting(): Promise<{
|
|
85
|
+
walletInfo: WalletInfo;
|
|
86
|
+
duplicateCheck: DuplicateCheckResult;
|
|
87
|
+
gasCosts?: {
|
|
88
|
+
gasLimit: bigint;
|
|
89
|
+
gasPrice: bigint;
|
|
90
|
+
estimatedCost: string;
|
|
91
|
+
};
|
|
92
|
+
mintingResult?: MintingResult;
|
|
93
|
+
tokenMetadata?: TokenMetadata;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Complete the minting after user confirmation
|
|
97
|
+
*/
|
|
98
|
+
completeMinting(): Promise<{
|
|
99
|
+
mintingResult: MintingResult;
|
|
100
|
+
tokenMetadata?: TokenMetadata;
|
|
101
|
+
}>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Utility function to validate Ethereum private key
|
|
105
|
+
*/
|
|
106
|
+
export declare function validatePrivateKey(privateKey: string): boolean;
|