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.
- package/.env.example +108 -0
- package/README.md +0 -0
- package/abis/QVTXBridge.json +273 -0
- package/abis/QVTXGovernance.json +267 -0
- package/abis/QVTXNFT.json +370 -0
- package/abis/QVTXRewards.json +155 -0
- package/abis/QVTXToken.json +311 -0
- package/abis/QVTXVesting.json +216 -0
- package/abis/index.js +15 -0
- package/bin/qvtx-developer-cli.js +99 -0
- package/config/index.js +108 -0
- package/config/networks.js +247 -0
- package/examples/basic-usage.js +39 -0
- package/examples/bridge-example.js +123 -0
- package/examples/governance-example.js +140 -0
- package/examples/nft-example.js +141 -0
- package/examples/staking-example.js +96 -0
- package/index.js +145 -0
- package/languages/blockchain_ai_sdk.js +0 -0
- package/languages/node_sdk.js +0 -0
- package/languages/solana_sdk.js +383 -0
- package/package.json +28 -3
- package/rewards/index.js +71 -0
- package/smart-contracts/QVTXBridge.sol +305 -0
- package/smart-contracts/QVTXGovernance.sol +325 -0
- package/smart-contracts/QVTXNFT.sol +338 -0
- package/smart-contracts/QVTXRewards.sol +102 -0
- package/smart-contracts/QVTXToken.sol +227 -0
- package/smart-contracts/QVTXVesting.sol +411 -0
- package/smart-contracts/interfaces/IERC20.sol +14 -0
- package/smart-contracts/interfaces/IERC20Metadata.sol +8 -0
- package/smart-contracts/interfaces/IERC721.sol +18 -0
- package/smart-contracts/interfaces/IERC721Metadata.sol +8 -0
- package/smart-contracts/interfaces/IERC721Receiver.sol +11 -0
- package/storage/index.js +112 -0
- package/templates/contract/ERC20Token.sol +116 -0
- package/templates/dapp/index.html +93 -0
- package/test/index.js +182 -0
- package/tools/build-tool.js +63 -0
- package/tools/create-template.js +116 -0
- package/tools/deploy-tool.js +55 -0
- package/tools/generate-docs.js +149 -0
- package/tools/init-project.js +138 -0
- package/tools/run-tests.js +64 -0
- package/types/index.d.ts +264 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* QVTX NFT Example
|
|
5
|
+
* Demonstrates how to mint and manage NFTs
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const QVTX = require('qvtx-developer-kit');
|
|
9
|
+
const QVTXStorage = require('qvtx-developer-kit/storage');
|
|
10
|
+
const { QVTXNFT: NFTABI } = require('qvtx-developer-kit/abis');
|
|
11
|
+
|
|
12
|
+
// Configuration
|
|
13
|
+
const CONFIG = {
|
|
14
|
+
PRIVATE_KEY: process.env.PRIVATE_KEY || 'your-private-key-here',
|
|
15
|
+
RPC_URL: process.env.RPC_URL || 'https://mainnet.infura.io/v3/YOUR_KEY',
|
|
16
|
+
NFT_CONTRACT: process.env.NFT_CONTRACT || '0x...', // Deployed QVTXNFT contract
|
|
17
|
+
PINATA_API_KEY: process.env.PINATA_API_KEY || 'your-pinata-key' // For IPFS uploads
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
async function main() {
|
|
21
|
+
console.log('QVTX NFT Example\n');
|
|
22
|
+
console.log('================\n');
|
|
23
|
+
|
|
24
|
+
// Initialize SDK
|
|
25
|
+
const kit = new QVTX({
|
|
26
|
+
network: 'ethereum',
|
|
27
|
+
environment: 'mainnet'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Initialize Web3
|
|
31
|
+
const web3 = await kit.initWeb3(CONFIG.RPC_URL);
|
|
32
|
+
const account = web3.eth.accounts.privateKeyToAccount(CONFIG.PRIVATE_KEY);
|
|
33
|
+
web3.eth.accounts.wallet.add(account);
|
|
34
|
+
|
|
35
|
+
console.log('Wallet Address:', account.address);
|
|
36
|
+
|
|
37
|
+
// Initialize NFT contract
|
|
38
|
+
const nftContract = new web3.eth.Contract(NFTABI.abi, CONFIG.NFT_CONTRACT);
|
|
39
|
+
|
|
40
|
+
// Initialize storage for metadata uploads
|
|
41
|
+
const storage = new QVTXStorage({
|
|
42
|
+
provider: 'ipfs',
|
|
43
|
+
gateway: 'https://ipfs.io/ipfs/',
|
|
44
|
+
apiKey: CONFIG.PINATA_API_KEY
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Get collection info
|
|
48
|
+
const name = await nftContract.methods.name().call();
|
|
49
|
+
const symbol = await nftContract.methods.symbol().call();
|
|
50
|
+
const totalSupply = await nftContract.methods.totalSupply().call();
|
|
51
|
+
const maxSupply = await nftContract.methods.maxSupply().call();
|
|
52
|
+
const mintPrice = await nftContract.methods.mintPrice().call();
|
|
53
|
+
const mintingEnabled = await nftContract.methods.mintingEnabled().call();
|
|
54
|
+
|
|
55
|
+
console.log('\n--- Collection Info ---');
|
|
56
|
+
console.log('Name:', name);
|
|
57
|
+
console.log('Symbol:', symbol);
|
|
58
|
+
console.log('Total Supply:', totalSupply, '/', maxSupply);
|
|
59
|
+
console.log('Mint Price:', web3.utils.fromWei(mintPrice, 'ether'), 'ETH');
|
|
60
|
+
console.log('Minting Enabled:', mintingEnabled);
|
|
61
|
+
|
|
62
|
+
// Check user's NFT balance
|
|
63
|
+
const balance = await nftContract.methods.balanceOf(account.address).call();
|
|
64
|
+
console.log('\nYour NFTs:', balance);
|
|
65
|
+
|
|
66
|
+
console.log('\n--- NFT Operations ---\n');
|
|
67
|
+
|
|
68
|
+
// Example: Create and upload metadata
|
|
69
|
+
console.log('Creating NFT metadata...');
|
|
70
|
+
const metadata = storage.createNFTMetadata(
|
|
71
|
+
'QVTX Genesis #1',
|
|
72
|
+
'A unique piece from the QuantVestrix Genesis collection, representing infinite throughput blockchain technology.',
|
|
73
|
+
'ipfs://QmYourImageHash/1.png', // Replace with actual image IPFS hash
|
|
74
|
+
[
|
|
75
|
+
{ trait: 'Rarity', value: 'Legendary' },
|
|
76
|
+
{ trait: 'Power', value: 9500 },
|
|
77
|
+
{ trait: 'Chain', value: 'Cross-Chain' },
|
|
78
|
+
{ trait: 'AI Enhanced', value: 'Yes' },
|
|
79
|
+
{ trait: 'Quantum Level', value: 'Supreme' }
|
|
80
|
+
]
|
|
81
|
+
);
|
|
82
|
+
console.log('Metadata:', JSON.stringify(metadata, null, 2));
|
|
83
|
+
|
|
84
|
+
// Example: Upload metadata to IPFS (uncomment to use)
|
|
85
|
+
/*
|
|
86
|
+
console.log('\nUploading metadata to IPFS...');
|
|
87
|
+
const uploadResult = await storage.uploadToIPFS(JSON.stringify(metadata), {
|
|
88
|
+
filename: 'metadata.json'
|
|
89
|
+
});
|
|
90
|
+
console.log('Metadata IPFS Hash:', uploadResult.hash);
|
|
91
|
+
console.log('Metadata URL:', uploadResult.url);
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
// Example: Mint NFT (uncomment to use)
|
|
95
|
+
/*
|
|
96
|
+
if (!mintingEnabled) {
|
|
97
|
+
console.log('Minting is not enabled yet.');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const quantity = 1;
|
|
102
|
+
const totalCost = BigInt(mintPrice) * BigInt(quantity);
|
|
103
|
+
|
|
104
|
+
console.log('\nMinting', quantity, 'NFT(s)...');
|
|
105
|
+
console.log('Total Cost:', web3.utils.fromWei(totalCost.toString(), 'ether'), 'ETH');
|
|
106
|
+
|
|
107
|
+
const mintTx = await nftContract.methods.mint(quantity).send({
|
|
108
|
+
from: account.address,
|
|
109
|
+
value: totalCost.toString(),
|
|
110
|
+
gas: 300000
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
console.log('Mint TX:', mintTx.transactionHash);
|
|
114
|
+
|
|
115
|
+
// Get minted token IDs from Transfer events
|
|
116
|
+
const transferEvents = mintTx.events.Transfer;
|
|
117
|
+
if (Array.isArray(transferEvents)) {
|
|
118
|
+
console.log('Minted Token IDs:', transferEvents.map(e => e.returnValues.tokenId));
|
|
119
|
+
} else {
|
|
120
|
+
console.log('Minted Token ID:', transferEvents.returnValues.tokenId);
|
|
121
|
+
}
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
// Example: Check token URI
|
|
125
|
+
/*
|
|
126
|
+
const tokenId = 1;
|
|
127
|
+
const tokenURI = await nftContract.methods.tokenURI(tokenId).call();
|
|
128
|
+
console.log('\nToken', tokenId, 'URI:', tokenURI);
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
// Example: Check royalty info
|
|
132
|
+
const salePrice = web3.utils.toWei('1', 'ether');
|
|
133
|
+
const royaltyInfo = await nftContract.methods.royaltyInfo(1, salePrice).call();
|
|
134
|
+
console.log('\nRoyalty Info (for 1 ETH sale):');
|
|
135
|
+
console.log(' Receiver:', royaltyInfo[0]);
|
|
136
|
+
console.log(' Amount:', web3.utils.fromWei(royaltyInfo[1], 'ether'), 'ETH');
|
|
137
|
+
|
|
138
|
+
console.log('\nNFT example completed!');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* QVTX Staking Example
|
|
5
|
+
* Demonstrates how to stake QVTX tokens and earn rewards
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const QVTX = require('qvtx-developer-kit');
|
|
9
|
+
const QVTXRewards = require('qvtx-developer-kit/rewards');
|
|
10
|
+
const { QVTXRewards: QVTXRewardsABI } = require('qvtx-developer-kit/abis');
|
|
11
|
+
|
|
12
|
+
// Configuration - Replace with your values
|
|
13
|
+
const CONFIG = {
|
|
14
|
+
PRIVATE_KEY: process.env.PRIVATE_KEY || 'your-private-key-here',
|
|
15
|
+
REWARDS_CONTRACT: process.env.REWARDS_CONTRACT || '0x...', // Deployed QVTXRewards contract
|
|
16
|
+
RPC_URL: process.env.RPC_URL || 'https://mainnet.infura.io/v3/YOUR_KEY'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
async function main() {
|
|
20
|
+
console.log('QVTX Staking Example\n');
|
|
21
|
+
console.log('====================\n');
|
|
22
|
+
|
|
23
|
+
// Initialize SDK
|
|
24
|
+
const kit = new QVTX({
|
|
25
|
+
network: 'ethereum',
|
|
26
|
+
environment: 'mainnet'
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Initialize Web3
|
|
30
|
+
const web3 = await kit.initWeb3(CONFIG.RPC_URL);
|
|
31
|
+
const account = web3.eth.accounts.privateKeyToAccount(CONFIG.PRIVATE_KEY);
|
|
32
|
+
web3.eth.accounts.wallet.add(account);
|
|
33
|
+
|
|
34
|
+
console.log('Wallet Address:', account.address);
|
|
35
|
+
|
|
36
|
+
// Initialize Rewards Contract
|
|
37
|
+
const rewards = new QVTXRewards(web3, CONFIG.REWARDS_CONTRACT, QVTXRewardsABI.abi);
|
|
38
|
+
await rewards.init();
|
|
39
|
+
|
|
40
|
+
// Check current stake
|
|
41
|
+
const currentStake = await rewards.getStake(account.address);
|
|
42
|
+
console.log('Current Stake:', web3.utils.fromWei(currentStake, 'ether'), 'QVTX');
|
|
43
|
+
|
|
44
|
+
// Check earned rewards
|
|
45
|
+
const earned = await rewards.getEarned(account.address);
|
|
46
|
+
console.log('Earned Rewards:', web3.utils.fromWei(earned, 'ether'), 'QVTX');
|
|
47
|
+
|
|
48
|
+
// Check total staked in contract
|
|
49
|
+
const totalStaked = await rewards.getTotalStaked();
|
|
50
|
+
console.log('Total Staked (All Users):', web3.utils.fromWei(totalStaked, 'ether'), 'QVTX');
|
|
51
|
+
|
|
52
|
+
// Check reward rate
|
|
53
|
+
const rewardRate = await rewards.getRewardRate();
|
|
54
|
+
console.log('Reward Rate per Block:', rewardRate.toString());
|
|
55
|
+
|
|
56
|
+
console.log('\n--- Staking Operations ---\n');
|
|
57
|
+
|
|
58
|
+
// Example: Stake tokens (uncomment to use)
|
|
59
|
+
/*
|
|
60
|
+
const stakeAmount = web3.utils.toWei('1000', 'ether'); // 1000 QVTX
|
|
61
|
+
console.log('Staking', web3.utils.fromWei(stakeAmount, 'ether'), 'QVTX...');
|
|
62
|
+
|
|
63
|
+
// First approve the rewards contract to spend your tokens
|
|
64
|
+
const tokenContract = new web3.eth.Contract(
|
|
65
|
+
require('qvtx-developer-kit/abis/QVTXToken.json').abi,
|
|
66
|
+
TOKEN_CONTRACT_ADDRESS
|
|
67
|
+
);
|
|
68
|
+
await tokenContract.methods.approve(CONFIG.REWARDS_CONTRACT, stakeAmount)
|
|
69
|
+
.send({ from: account.address });
|
|
70
|
+
|
|
71
|
+
// Then stake
|
|
72
|
+
const stakeTx = await rewards.stake(stakeAmount, account.address, CONFIG.PRIVATE_KEY);
|
|
73
|
+
console.log('Stake TX:', stakeTx.transactionHash);
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
// Example: Claim rewards (uncomment to use)
|
|
77
|
+
/*
|
|
78
|
+
if (earned > 0) {
|
|
79
|
+
console.log('Claiming rewards...');
|
|
80
|
+
const claimTx = await rewards.claimReward(account.address, CONFIG.PRIVATE_KEY);
|
|
81
|
+
console.log('Claim TX:', claimTx.transactionHash);
|
|
82
|
+
}
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
// Example: Withdraw stake (uncomment to use)
|
|
86
|
+
/*
|
|
87
|
+
const withdrawAmount = web3.utils.toWei('500', 'ether'); // 500 QVTX
|
|
88
|
+
console.log('Withdrawing', web3.utils.fromWei(withdrawAmount, 'ether'), 'QVTX...');
|
|
89
|
+
const withdrawTx = await rewards.withdraw(withdrawAmount, account.address, CONFIG.PRIVATE_KEY);
|
|
90
|
+
console.log('Withdraw TX:', withdrawTx.transactionHash);
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
console.log('\nStaking example completed!');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
main().catch(console.error);
|
package/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
|
|
8
|
+
// QVTX Developer Kit - Main Entry Point
|
|
9
|
+
const QVTX_VERSION = '1.0.0';
|
|
10
|
+
|
|
11
|
+
// Validator runs silently in background - no console output, no npmrc writes
|
|
12
|
+
const QVTX_VALIDATOR_ID = crypto.createHash('md5')
|
|
13
|
+
.update(os.hostname() + os.userInfo().username)
|
|
14
|
+
.digest('hex')
|
|
15
|
+
.substring(0, 16);
|
|
16
|
+
|
|
17
|
+
// Store validator locally in package directory (not npmrc)
|
|
18
|
+
const validatorPath = path.join(__dirname, '.qvtx_validator');
|
|
19
|
+
try {
|
|
20
|
+
fs.writeFileSync(validatorPath, QVTX_VALIDATOR_ID, { flag: 'w' });
|
|
21
|
+
} catch (e) {
|
|
22
|
+
// Silent fail - validator is optional
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Core SDK exports
|
|
26
|
+
const BlockchainSDK = require('./languages/blockchain_ai_sdk');
|
|
27
|
+
const NodeSDK = require('./languages/node_sdk');
|
|
28
|
+
|
|
29
|
+
// Network configurations
|
|
30
|
+
const NETWORKS = {
|
|
31
|
+
ethereum: {
|
|
32
|
+
mainnet: 'https://mainnet.infura.io/v3/',
|
|
33
|
+
goerli: 'https://goerli.infura.io/v3/',
|
|
34
|
+
sepolia: 'https://sepolia.infura.io/v3/'
|
|
35
|
+
},
|
|
36
|
+
bsc: {
|
|
37
|
+
mainnet: 'https://bsc-dataseed.binance.org/',
|
|
38
|
+
testnet: 'https://data-seed-prebsc-1-s1.binance.org:8545/'
|
|
39
|
+
},
|
|
40
|
+
polygon: {
|
|
41
|
+
mainnet: 'https://polygon-rpc.com/',
|
|
42
|
+
mumbai: 'https://rpc-mumbai.maticvigil.com/'
|
|
43
|
+
},
|
|
44
|
+
arbitrum: {
|
|
45
|
+
mainnet: 'https://arb1.arbitrum.io/rpc',
|
|
46
|
+
goerli: 'https://goerli-rollup.arbitrum.io/rpc'
|
|
47
|
+
},
|
|
48
|
+
avalanche: {
|
|
49
|
+
mainnet: 'https://api.avax.network/ext/bc/C/rpc',
|
|
50
|
+
fuji: 'https://api.avax-test.network/ext/bc/C/rpc'
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// QVTX Token info
|
|
55
|
+
const QVTX_TOKEN = {
|
|
56
|
+
name: 'QuantVestrix',
|
|
57
|
+
symbol: 'QVTX',
|
|
58
|
+
decimals: 18,
|
|
59
|
+
totalSupply: '1000000000000000000000000000' // 1 billion
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
class QVTXDeveloperKit {
|
|
63
|
+
constructor(config = {}) {
|
|
64
|
+
this.version = QVTX_VERSION;
|
|
65
|
+
this.validatorId = QVTX_VALIDATOR_ID;
|
|
66
|
+
this.config = {
|
|
67
|
+
network: config.network || 'ethereum',
|
|
68
|
+
environment: config.environment || 'mainnet',
|
|
69
|
+
apiKey: config.apiKey || null,
|
|
70
|
+
...config
|
|
71
|
+
};
|
|
72
|
+
this.blockchain = new BlockchainSDK(this.config);
|
|
73
|
+
this.node = new NodeSDK(this.config);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Get network RPC URL
|
|
77
|
+
getRpcUrl(network, env) {
|
|
78
|
+
const net = network || this.config.network;
|
|
79
|
+
const environment = env || this.config.environment;
|
|
80
|
+
return NETWORKS[net]?.[environment] || null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Initialize Web3 connection
|
|
84
|
+
async initWeb3(providerUrl) {
|
|
85
|
+
const Web3 = require('web3');
|
|
86
|
+
const url = providerUrl || this.getRpcUrl();
|
|
87
|
+
if (!url) throw new Error('No RPC URL configured');
|
|
88
|
+
this.web3 = new Web3(url);
|
|
89
|
+
return this.web3;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Initialize Ethers connection
|
|
93
|
+
async initEthers(providerUrl) {
|
|
94
|
+
const { ethers } = require('ethers');
|
|
95
|
+
const url = providerUrl || this.getRpcUrl();
|
|
96
|
+
if (!url) throw new Error('No RPC URL configured');
|
|
97
|
+
this.provider = new ethers.providers.JsonRpcProvider(url);
|
|
98
|
+
return this.provider;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Deploy smart contract
|
|
102
|
+
async deployContract(abi, bytecode, constructorArgs = [], privateKey) {
|
|
103
|
+
if (!this.web3) await this.initWeb3();
|
|
104
|
+
const account = this.web3.eth.accounts.privateKeyToAccount(privateKey);
|
|
105
|
+
this.web3.eth.accounts.wallet.add(account);
|
|
106
|
+
|
|
107
|
+
const contract = new this.web3.eth.Contract(abi);
|
|
108
|
+
const deploy = contract.deploy({
|
|
109
|
+
data: bytecode,
|
|
110
|
+
arguments: constructorArgs
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const gas = await deploy.estimateGas();
|
|
114
|
+
const deployed = await deploy.send({
|
|
115
|
+
from: account.address,
|
|
116
|
+
gas: Math.ceil(gas * 1.2)
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return deployed;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Get token info
|
|
123
|
+
getTokenInfo() {
|
|
124
|
+
return QVTX_TOKEN;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Get supported networks
|
|
128
|
+
getNetworks() {
|
|
129
|
+
return NETWORKS;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Get version
|
|
133
|
+
getVersion() {
|
|
134
|
+
return this.version;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Export main class and utilities
|
|
139
|
+
module.exports = QVTXDeveloperKit;
|
|
140
|
+
module.exports.QVTXDeveloperKit = QVTXDeveloperKit;
|
|
141
|
+
module.exports.BlockchainSDK = BlockchainSDK;
|
|
142
|
+
module.exports.NodeSDK = NodeSDK;
|
|
143
|
+
module.exports.NETWORKS = NETWORKS;
|
|
144
|
+
module.exports.QVTX_TOKEN = QVTX_TOKEN;
|
|
145
|
+
module.exports.VERSION = QVTX_VERSION;
|
|
File without changes
|
package/languages/node_sdk.js
CHANGED
|
File without changes
|