qvtx-developer-kit 1.0.0 → 1.1.0

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 (45) hide show
  1. package/.env.example +108 -0
  2. package/README.md +0 -0
  3. package/abis/QVTXBridge.json +273 -0
  4. package/abis/QVTXGovernance.json +267 -0
  5. package/abis/QVTXNFT.json +370 -0
  6. package/abis/QVTXRewards.json +155 -0
  7. package/abis/QVTXToken.json +311 -0
  8. package/abis/QVTXVesting.json +216 -0
  9. package/abis/index.js +15 -0
  10. package/bin/qvtx-developer-cli.js +99 -0
  11. package/config/index.js +108 -0
  12. package/config/networks.js +247 -0
  13. package/examples/basic-usage.js +39 -0
  14. package/examples/bridge-example.js +123 -0
  15. package/examples/governance-example.js +140 -0
  16. package/examples/nft-example.js +141 -0
  17. package/examples/staking-example.js +96 -0
  18. package/index.js +145 -0
  19. package/languages/blockchain_ai_sdk.js +0 -0
  20. package/languages/node_sdk.js +0 -0
  21. package/languages/solana_sdk.js +383 -0
  22. package/package.json +28 -3
  23. package/rewards/index.js +71 -0
  24. package/smart-contracts/QVTXBridge.sol +305 -0
  25. package/smart-contracts/QVTXGovernance.sol +325 -0
  26. package/smart-contracts/QVTXNFT.sol +338 -0
  27. package/smart-contracts/QVTXRewards.sol +102 -0
  28. package/smart-contracts/QVTXToken.sol +227 -0
  29. package/smart-contracts/QVTXVesting.sol +411 -0
  30. package/smart-contracts/interfaces/IERC20.sol +14 -0
  31. package/smart-contracts/interfaces/IERC20Metadata.sol +8 -0
  32. package/smart-contracts/interfaces/IERC721.sol +18 -0
  33. package/smart-contracts/interfaces/IERC721Metadata.sol +8 -0
  34. package/smart-contracts/interfaces/IERC721Receiver.sol +11 -0
  35. package/storage/index.js +112 -0
  36. package/templates/contract/ERC20Token.sol +116 -0
  37. package/templates/dapp/index.html +93 -0
  38. package/test/index.js +182 -0
  39. package/tools/build-tool.js +63 -0
  40. package/tools/create-template.js +116 -0
  41. package/tools/deploy-tool.js +55 -0
  42. package/tools/generate-docs.js +149 -0
  43. package/tools/init-project.js +138 -0
  44. package/tools/run-tests.js +64 -0
  45. package/types/index.d.ts +264 -0
@@ -0,0 +1,383 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * QuantVestrix QVTX Solana SDK
5
+ *
6
+ * Solana blockchain integration for QVTX ecosystem
7
+ * Supports SPL tokens, NFTs, and cross-chain operations
8
+ *
9
+ * @author QuantVestrix Tech Team (07-Tech)
10
+ * @version 1.0.0
11
+ */
12
+
13
+ const {
14
+ Connection,
15
+ PublicKey,
16
+ Keypair,
17
+ Transaction,
18
+ SystemProgram,
19
+ LAMPORTS_PER_SOL,
20
+ sendAndConfirmTransaction
21
+ } = require('@solana/web3.js');
22
+
23
+ const {
24
+ createMint,
25
+ getMint,
26
+ getOrCreateAssociatedTokenAccount,
27
+ mintTo,
28
+ transfer,
29
+ getAccount,
30
+ TOKEN_PROGRAM_ID
31
+ } = require('@solana/spl-token');
32
+
33
+ class QVTXSolana {
34
+ constructor(config = {}) {
35
+ this.network = config.network || 'devnet';
36
+ this.rpcUrl = config.rpcUrl || this._getDefaultRpcUrl();
37
+ this.connection = null;
38
+ this.commitment = config.commitment || 'confirmed';
39
+
40
+ console.log('🌊 QVTX Solana SDK Initialized');
41
+ console.log('📡 Network:', this.network);
42
+ }
43
+
44
+ _getDefaultRpcUrl() {
45
+ const urls = {
46
+ 'mainnet-beta': 'https://api.mainnet-beta.solana.com',
47
+ 'devnet': 'https://api.devnet.solana.com',
48
+ 'testnet': 'https://api.testnet.solana.com'
49
+ };
50
+ return urls[this.network] || urls['devnet'];
51
+ }
52
+
53
+ // Connect to Solana network
54
+ async connect() {
55
+ this.connection = new Connection(this.rpcUrl, this.commitment);
56
+ const version = await this.connection.getVersion();
57
+ console.log('✅ Connected to Solana');
58
+ console.log(' Version:', version['solana-core']);
59
+ return this.connection;
60
+ }
61
+
62
+ // Get connection (auto-connect if needed)
63
+ async getConnection() {
64
+ if (!this.connection) {
65
+ await this.connect();
66
+ }
67
+ return this.connection;
68
+ }
69
+
70
+ // Generate new keypair
71
+ generateKeypair() {
72
+ const keypair = Keypair.generate();
73
+ return {
74
+ publicKey: keypair.publicKey.toString(),
75
+ secretKey: Buffer.from(keypair.secretKey).toString('hex'),
76
+ keypair
77
+ };
78
+ }
79
+
80
+ // Load keypair from secret key
81
+ loadKeypair(secretKey) {
82
+ const secretKeyArray = typeof secretKey === 'string'
83
+ ? Uint8Array.from(Buffer.from(secretKey, 'hex'))
84
+ : secretKey;
85
+ return Keypair.fromSecretKey(secretKeyArray);
86
+ }
87
+
88
+ // Get SOL balance
89
+ async getBalance(publicKey) {
90
+ const connection = await this.getConnection();
91
+ const pubKey = typeof publicKey === 'string' ? new PublicKey(publicKey) : publicKey;
92
+ const balance = await connection.getBalance(pubKey);
93
+ return balance / LAMPORTS_PER_SOL;
94
+ }
95
+
96
+ // Request airdrop (devnet/testnet only)
97
+ async requestAirdrop(publicKey, amount = 1) {
98
+ if (this.network === 'mainnet-beta') {
99
+ throw new Error('Airdrop not available on mainnet');
100
+ }
101
+
102
+ const connection = await this.getConnection();
103
+ const pubKey = typeof publicKey === 'string' ? new PublicKey(publicKey) : publicKey;
104
+
105
+ console.log(`💰 Requesting ${amount} SOL airdrop...`);
106
+ const signature = await connection.requestAirdrop(
107
+ pubKey,
108
+ amount * LAMPORTS_PER_SOL
109
+ );
110
+
111
+ await connection.confirmTransaction(signature);
112
+ console.log('✅ Airdrop received!');
113
+ return signature;
114
+ }
115
+
116
+ // Transfer SOL
117
+ async transfer(fromKeypair, toPublicKey, amount) {
118
+ const connection = await this.getConnection();
119
+ const toPubKey = typeof toPublicKey === 'string' ? new PublicKey(toPublicKey) : toPublicKey;
120
+
121
+ console.log(`📤 Transferring ${amount} SOL...`);
122
+
123
+ const transaction = new Transaction().add(
124
+ SystemProgram.transfer({
125
+ fromPubkey: fromKeypair.publicKey,
126
+ toPubkey: toPubKey,
127
+ lamports: amount * LAMPORTS_PER_SOL
128
+ })
129
+ );
130
+
131
+ const signature = await sendAndConfirmTransaction(
132
+ connection,
133
+ transaction,
134
+ [fromKeypair]
135
+ );
136
+
137
+ console.log('✅ Transfer complete!');
138
+ console.log(' Signature:', signature);
139
+ return signature;
140
+ }
141
+
142
+ // Create SPL Token (QVTX on Solana)
143
+ async createToken(authority, decimals = 9) {
144
+ const connection = await this.getConnection();
145
+
146
+ console.log('🪙 Creating SPL Token...');
147
+
148
+ const mint = await createMint(
149
+ connection,
150
+ authority,
151
+ authority.publicKey,
152
+ authority.publicKey,
153
+ decimals
154
+ );
155
+
156
+ console.log('✅ Token created!');
157
+ console.log(' Mint Address:', mint.toString());
158
+ return mint.toString();
159
+ }
160
+
161
+ // Get token info
162
+ async getTokenInfo(mintAddress) {
163
+ const connection = await this.getConnection();
164
+ const mintPubKey = new PublicKey(mintAddress);
165
+
166
+ const mintInfo = await getMint(connection, mintPubKey);
167
+
168
+ return {
169
+ address: mintAddress,
170
+ decimals: mintInfo.decimals,
171
+ supply: Number(mintInfo.supply) / Math.pow(10, mintInfo.decimals),
172
+ mintAuthority: mintInfo.mintAuthority?.toString(),
173
+ freezeAuthority: mintInfo.freezeAuthority?.toString(),
174
+ isInitialized: mintInfo.isInitialized
175
+ };
176
+ }
177
+
178
+ // Create token account
179
+ async createTokenAccount(mint, owner, payer) {
180
+ const connection = await this.getConnection();
181
+ const mintPubKey = new PublicKey(mint);
182
+ const ownerPubKey = typeof owner === 'string' ? new PublicKey(owner) : owner.publicKey || owner;
183
+
184
+ console.log('📦 Creating token account...');
185
+
186
+ const tokenAccount = await getOrCreateAssociatedTokenAccount(
187
+ connection,
188
+ payer,
189
+ mintPubKey,
190
+ ownerPubKey
191
+ );
192
+
193
+ console.log('✅ Token account created!');
194
+ console.log(' Address:', tokenAccount.address.toString());
195
+ return tokenAccount.address.toString();
196
+ }
197
+
198
+ // Mint tokens
199
+ async mintTokens(mint, destination, authority, amount) {
200
+ const connection = await this.getConnection();
201
+ const mintPubKey = new PublicKey(mint);
202
+ const destPubKey = new PublicKey(destination);
203
+
204
+ console.log(`🔨 Minting ${amount} tokens...`);
205
+
206
+ const mintInfo = await getMint(connection, mintPubKey);
207
+ const adjustedAmount = amount * Math.pow(10, mintInfo.decimals);
208
+
209
+ const signature = await mintTo(
210
+ connection,
211
+ authority,
212
+ mintPubKey,
213
+ destPubKey,
214
+ authority,
215
+ adjustedAmount
216
+ );
217
+
218
+ console.log('✅ Tokens minted!');
219
+ console.log(' Signature:', signature);
220
+ return signature;
221
+ }
222
+
223
+ // Transfer tokens
224
+ async transferTokens(mint, from, to, owner, amount) {
225
+ const connection = await this.getConnection();
226
+ const mintPubKey = new PublicKey(mint);
227
+ const fromPubKey = new PublicKey(from);
228
+ const toPubKey = new PublicKey(to);
229
+
230
+ console.log(`📤 Transferring ${amount} tokens...`);
231
+
232
+ const mintInfo = await getMint(connection, mintPubKey);
233
+ const adjustedAmount = amount * Math.pow(10, mintInfo.decimals);
234
+
235
+ const signature = await transfer(
236
+ connection,
237
+ owner,
238
+ fromPubKey,
239
+ toPubKey,
240
+ owner,
241
+ adjustedAmount
242
+ );
243
+
244
+ console.log('✅ Tokens transferred!');
245
+ console.log(' Signature:', signature);
246
+ return signature;
247
+ }
248
+
249
+ // Get token balance
250
+ async getTokenBalance(tokenAccount) {
251
+ const connection = await this.getConnection();
252
+ const accountPubKey = new PublicKey(tokenAccount);
253
+
254
+ const accountInfo = await getAccount(connection, accountPubKey);
255
+
256
+ // Get decimals from mint
257
+ const mintInfo = await getMint(connection, accountInfo.mint);
258
+
259
+ return Number(accountInfo.amount) / Math.pow(10, mintInfo.decimals);
260
+ }
261
+
262
+ // Get recent blockhash
263
+ async getRecentBlockhash() {
264
+ const connection = await this.getConnection();
265
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
266
+ return { blockhash, lastValidBlockHeight };
267
+ }
268
+
269
+ // Get transaction
270
+ async getTransaction(signature) {
271
+ const connection = await this.getConnection();
272
+ return await connection.getTransaction(signature, {
273
+ maxSupportedTransactionVersion: 0
274
+ });
275
+ }
276
+
277
+ // Get account info
278
+ async getAccountInfo(publicKey) {
279
+ const connection = await this.getConnection();
280
+ const pubKey = typeof publicKey === 'string' ? new PublicKey(publicKey) : publicKey;
281
+ return await connection.getAccountInfo(pubKey);
282
+ }
283
+
284
+ // Monitor transaction
285
+ async waitForConfirmation(signature, timeout = 60000) {
286
+ const connection = await this.getConnection();
287
+ const startTime = Date.now();
288
+
289
+ while (Date.now() - startTime < timeout) {
290
+ const status = await connection.getSignatureStatus(signature);
291
+
292
+ if (status.value?.confirmationStatus === 'confirmed' ||
293
+ status.value?.confirmationStatus === 'finalized') {
294
+ return status.value;
295
+ }
296
+
297
+ if (status.value?.err) {
298
+ throw new Error(`Transaction failed: ${JSON.stringify(status.value.err)}`);
299
+ }
300
+
301
+ await new Promise(resolve => setTimeout(resolve, 1000));
302
+ }
303
+
304
+ throw new Error('Transaction confirmation timeout');
305
+ }
306
+
307
+ // Get network status
308
+ async getStatus() {
309
+ const connection = await this.getConnection();
310
+
311
+ const [slot, blockHeight, epochInfo, supply] = await Promise.all([
312
+ connection.getSlot(),
313
+ connection.getBlockHeight(),
314
+ connection.getEpochInfo(),
315
+ connection.getSupply()
316
+ ]);
317
+
318
+ return {
319
+ network: this.network,
320
+ rpcUrl: this.rpcUrl,
321
+ slot,
322
+ blockHeight,
323
+ epoch: epochInfo.epoch,
324
+ slotIndex: epochInfo.slotIndex,
325
+ slotsInEpoch: epochInfo.slotsInEpoch,
326
+ totalSupply: supply.value.total / LAMPORTS_PER_SOL,
327
+ circulatingSupply: supply.value.circulating / LAMPORTS_PER_SOL
328
+ };
329
+ }
330
+ }
331
+
332
+ // QVTX-specific Solana utilities
333
+ class QVTXSolanaBridge {
334
+ constructor(solanaSDK, config = {}) {
335
+ this.solana = solanaSDK;
336
+ this.qvtxMint = config.qvtxMint || null;
337
+ this.bridgeProgram = config.bridgeProgram || null;
338
+ }
339
+
340
+ // Set QVTX token mint address
341
+ setQVTXMint(mintAddress) {
342
+ this.qvtxMint = mintAddress;
343
+ }
344
+
345
+ // Get QVTX balance
346
+ async getQVTXBalance(owner) {
347
+ if (!this.qvtxMint) {
348
+ throw new Error('QVTX mint address not set');
349
+ }
350
+ // Implementation would get associated token account and balance
351
+ return 0;
352
+ }
353
+
354
+ // Bridge QVTX from Solana to EVM chain
355
+ async bridgeToEVM(amount, evmAddress, evmChainId, signer) {
356
+ console.log(`🌉 Bridging ${amount} QVTX to EVM chain ${evmChainId}...`);
357
+ // Implementation would interact with bridge program
358
+ return { signature: 'mock-signature', bridgeId: 'mock-bridge-id' };
359
+ }
360
+
361
+ // Receive QVTX from EVM chain
362
+ async receiveFromEVM(bridgeId, amount, proof, signer) {
363
+ console.log(`📥 Receiving ${amount} QVTX from EVM bridge...`);
364
+ // Implementation would verify proof and mint tokens
365
+ return { signature: 'mock-signature' };
366
+ }
367
+ }
368
+
369
+ module.exports = QVTXSolana;
370
+ module.exports.QVTXSolana = QVTXSolana;
371
+ module.exports.QVTXSolanaBridge = QVTXSolanaBridge;
372
+
373
+ // CLI Usage
374
+ if (require.main === module) {
375
+ const solana = new QVTXSolana({ network: 'devnet' });
376
+
377
+ (async () => {
378
+ await solana.connect();
379
+ const status = await solana.getStatus();
380
+ console.log('\nSolana Network Status:');
381
+ console.log(JSON.stringify(status, null, 2));
382
+ })().catch(console.error);
383
+ }
package/package.json CHANGED
@@ -1,13 +1,27 @@
1
1
  {
2
2
  "name": "qvtx-developer-kit",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Complete QuantVestrix QVTX Developer Package - Build infinite throughput blockchain applications with cross-chain rewards and neural storage",
5
5
  "main": "index.js",
6
+ "types": "types/index.d.ts",
6
7
  "bin": {
7
8
  "qvtx-developer": "./bin/qvtx-developer-cli.js",
8
9
  "qvtx": "./bin/qvtx-developer-cli.js"
9
10
  },
11
+ "exports": {
12
+ ".": "./index.js",
13
+ "./abis": "./abis/index.js",
14
+ "./abis/*": "./abis/*.json",
15
+ "./rewards": "./rewards/index.js",
16
+ "./storage": "./storage/index.js",
17
+ "./config": "./config/index.js",
18
+ "./test": "./test/index.js",
19
+ "./solana": "./languages/solana_sdk.js",
20
+ "./blockchain-ai": "./languages/blockchain_ai_sdk.js",
21
+ "./node-sdk": "./languages/node_sdk.js"
22
+ },
10
23
  "files": [
24
+ "index.js",
11
25
  "languages/",
12
26
  "templates/",
13
27
  "docs/",
@@ -17,6 +31,11 @@
17
31
  "rewards/",
18
32
  "storage/",
19
33
  "bin/",
34
+ "abis/",
35
+ "types/",
36
+ "config/",
37
+ "test/",
38
+ ".env.example",
20
39
  "README.md",
21
40
  "CONTRIBUTING.md",
22
41
  "LICENSE"
@@ -50,7 +69,12 @@
50
69
  "smart-contracts",
51
70
  "dapp",
52
71
  "defi",
53
- "cryptocurrency"
72
+ "cryptocurrency",
73
+ "nft",
74
+ "governance",
75
+ "bridge",
76
+ "staking",
77
+ "vesting"
54
78
  ],
55
79
  "author": "QuantVestrix Tech Team (07-Tech)",
56
80
  "license": "MIT",
@@ -62,6 +86,7 @@
62
86
  "ethers": "^5.7.0",
63
87
  "axios": "^1.4.0",
64
88
  "@solana/web3.js": "^1.75.0",
89
+ "@solana/spl-token": "^0.3.8",
65
90
  "fs-extra": "^11.1.1",
66
91
  "chalk": "^5.2.0",
67
92
  "inquirer": "^9.2.11",
@@ -106,4 +131,4 @@
106
131
  "x64",
107
132
  "arm64"
108
133
  ]
109
- }
134
+ }
@@ -0,0 +1,71 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * QVTX Rewards Module
5
+ * Cross-chain rewards distribution utilities
6
+ */
7
+
8
+ class QVTXRewards {
9
+ constructor(web3, contractAddress, abi) {
10
+ this.web3 = web3;
11
+ this.contractAddress = contractAddress;
12
+ this.abi = abi || require('./QVTXRewardsABI.json');
13
+ this.contract = null;
14
+ }
15
+
16
+ async init() {
17
+ if (!this.web3) throw new Error('Web3 instance required');
18
+ this.contract = new this.web3.eth.Contract(this.abi, this.contractAddress);
19
+ return this;
20
+ }
21
+
22
+ async getStake(address) {
23
+ return await this.contract.methods.stakes(address).call();
24
+ }
25
+
26
+ async getEarned(address) {
27
+ return await this.contract.methods.earned(address).call();
28
+ }
29
+
30
+ async getTotalStaked() {
31
+ return await this.contract.methods.totalStaked().call();
32
+ }
33
+
34
+ async getRewardRate() {
35
+ return await this.contract.methods.rewardRate().call();
36
+ }
37
+
38
+ async stake(amount, fromAddress, privateKey) {
39
+ const tx = this.contract.methods.stake(amount);
40
+ return await this._sendTransaction(tx, fromAddress, privateKey);
41
+ }
42
+
43
+ async withdraw(amount, fromAddress, privateKey) {
44
+ const tx = this.contract.methods.withdraw(amount);
45
+ return await this._sendTransaction(tx, fromAddress, privateKey);
46
+ }
47
+
48
+ async claimReward(fromAddress, privateKey) {
49
+ const tx = this.contract.methods.claimReward();
50
+ return await this._sendTransaction(tx, fromAddress, privateKey);
51
+ }
52
+
53
+ async _sendTransaction(tx, fromAddress, privateKey) {
54
+ const gas = await tx.estimateGas({ from: fromAddress });
55
+ const data = tx.encodeABI();
56
+ const nonce = await this.web3.eth.getTransactionCount(fromAddress);
57
+ const gasPrice = await this.web3.eth.getGasPrice();
58
+
59
+ const signedTx = await this.web3.eth.accounts.signTransaction({
60
+ to: this.contractAddress,
61
+ data,
62
+ gas: Math.ceil(gas * 1.2),
63
+ gasPrice,
64
+ nonce
65
+ }, privateKey);
66
+
67
+ return await this.web3.eth.sendSignedTransaction(signedTx.rawTransaction);
68
+ }
69
+ }
70
+
71
+ module.exports = QVTXRewards;