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,338 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.19;
3
+
4
+ /**
5
+ * @title QVTX NFT
6
+ * @dev ERC721 NFT contract for QuantVestrix ecosystem
7
+ * @author QuantVestrix Tech Team (07-Tech)
8
+ */
9
+
10
+ import "./interfaces/IERC721.sol";
11
+ import "./interfaces/IERC721Metadata.sol";
12
+ import "./interfaces/IERC721Receiver.sol";
13
+
14
+ contract QVTXNFT is IERC721, IERC721Metadata {
15
+ string private _name;
16
+ string private _symbol;
17
+ string private _baseURI;
18
+
19
+ address public owner;
20
+ uint256 public totalSupply;
21
+ uint256 public maxSupply;
22
+ uint256 public mintPrice;
23
+ bool public mintingEnabled;
24
+
25
+ // Token data
26
+ mapping(uint256 => address) private _owners;
27
+ mapping(address => uint256) private _balances;
28
+ mapping(uint256 => address) private _tokenApprovals;
29
+ mapping(address => mapping(address => bool)) private _operatorApprovals;
30
+ mapping(uint256 => string) private _tokenURIs;
31
+
32
+ // Royalties (EIP-2981)
33
+ address public royaltyReceiver;
34
+ uint96 public royaltyBps = 500; // 5%
35
+
36
+ // Whitelist
37
+ mapping(address => bool) public whitelist;
38
+ mapping(address => uint256) public mintedCount;
39
+ uint256 public maxPerWallet = 10;
40
+ bool public whitelistOnly;
41
+
42
+ // Events
43
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
44
+ event BaseURIUpdated(string newBaseURI);
45
+ event MintingToggled(bool enabled);
46
+ event WhitelistUpdated(address indexed account, bool status);
47
+ event RoyaltyUpdated(address receiver, uint96 bps);
48
+
49
+ modifier onlyOwner() {
50
+ require(msg.sender == owner, "NFT: not owner");
51
+ _;
52
+ }
53
+
54
+ constructor(
55
+ string memory name_,
56
+ string memory symbol_,
57
+ string memory baseURI_,
58
+ uint256 _maxSupply,
59
+ uint256 _mintPrice
60
+ ) {
61
+ _name = name_;
62
+ _symbol = symbol_;
63
+ _baseURI = baseURI_;
64
+ maxSupply = _maxSupply;
65
+ mintPrice = _mintPrice;
66
+ owner = msg.sender;
67
+ royaltyReceiver = msg.sender;
68
+ }
69
+
70
+ // ERC721 Metadata
71
+ function name() external view override returns (string memory) {
72
+ return _name;
73
+ }
74
+
75
+ function symbol() external view override returns (string memory) {
76
+ return _symbol;
77
+ }
78
+
79
+ function tokenURI(uint256 tokenId) external view override returns (string memory) {
80
+ require(_exists(tokenId), "NFT: nonexistent token");
81
+
82
+ string memory _tokenURI = _tokenURIs[tokenId];
83
+ if (bytes(_tokenURI).length > 0) {
84
+ return _tokenURI;
85
+ }
86
+
87
+ return string(abi.encodePacked(_baseURI, _toString(tokenId), ".json"));
88
+ }
89
+
90
+ // ERC721 Standard
91
+ function balanceOf(address tokenOwner) external view override returns (uint256) {
92
+ require(tokenOwner != address(0), "NFT: zero address");
93
+ return _balances[tokenOwner];
94
+ }
95
+
96
+ function ownerOf(uint256 tokenId) public view override returns (address) {
97
+ address tokenOwner = _owners[tokenId];
98
+ require(tokenOwner != address(0), "NFT: nonexistent token");
99
+ return tokenOwner;
100
+ }
101
+
102
+ function approve(address to, uint256 tokenId) external override {
103
+ address tokenOwner = ownerOf(tokenId);
104
+ require(to != tokenOwner, "NFT: approval to owner");
105
+ require(
106
+ msg.sender == tokenOwner || isApprovedForAll(tokenOwner, msg.sender),
107
+ "NFT: not authorized"
108
+ );
109
+ _tokenApprovals[tokenId] = to;
110
+ emit Approval(tokenOwner, to, tokenId);
111
+ }
112
+
113
+ function getApproved(uint256 tokenId) public view override returns (address) {
114
+ require(_exists(tokenId), "NFT: nonexistent token");
115
+ return _tokenApprovals[tokenId];
116
+ }
117
+
118
+ function setApprovalForAll(address operator, bool approved) external override {
119
+ require(operator != msg.sender, "NFT: approve to caller");
120
+ _operatorApprovals[msg.sender][operator] = approved;
121
+ emit ApprovalForAll(msg.sender, operator, approved);
122
+ }
123
+
124
+ function isApprovedForAll(address tokenOwner, address operator) public view override returns (bool) {
125
+ return _operatorApprovals[tokenOwner][operator];
126
+ }
127
+
128
+ function transferFrom(address from, address to, uint256 tokenId) public override {
129
+ require(_isApprovedOrOwner(msg.sender, tokenId), "NFT: not authorized");
130
+ _transfer(from, to, tokenId);
131
+ }
132
+
133
+ function safeTransferFrom(address from, address to, uint256 tokenId) external override {
134
+ safeTransferFrom(from, to, tokenId, "");
135
+ }
136
+
137
+ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public override {
138
+ require(_isApprovedOrOwner(msg.sender, tokenId), "NFT: not authorized");
139
+ _safeTransfer(from, to, tokenId, data);
140
+ }
141
+
142
+ // Minting
143
+ function mint(uint256 quantity) external payable {
144
+ require(mintingEnabled, "NFT: minting disabled");
145
+ require(totalSupply + quantity <= maxSupply, "NFT: exceeds max supply");
146
+ require(mintedCount[msg.sender] + quantity <= maxPerWallet, "NFT: exceeds max per wallet");
147
+ require(msg.value >= mintPrice * quantity, "NFT: insufficient payment");
148
+
149
+ if (whitelistOnly) {
150
+ require(whitelist[msg.sender], "NFT: not whitelisted");
151
+ }
152
+
153
+ for (uint256 i = 0; i < quantity; i++) {
154
+ totalSupply++;
155
+ _mint(msg.sender, totalSupply);
156
+ }
157
+
158
+ mintedCount[msg.sender] += quantity;
159
+
160
+ // Refund excess
161
+ if (msg.value > mintPrice * quantity) {
162
+ payable(msg.sender).transfer(msg.value - mintPrice * quantity);
163
+ }
164
+ }
165
+
166
+ function ownerMint(address to, uint256 quantity) external onlyOwner {
167
+ require(totalSupply + quantity <= maxSupply, "NFT: exceeds max supply");
168
+
169
+ for (uint256 i = 0; i < quantity; i++) {
170
+ totalSupply++;
171
+ _mint(to, totalSupply);
172
+ }
173
+ }
174
+
175
+ function airdrop(address[] calldata recipients) external onlyOwner {
176
+ require(totalSupply + recipients.length <= maxSupply, "NFT: exceeds max supply");
177
+
178
+ for (uint256 i = 0; i < recipients.length; i++) {
179
+ totalSupply++;
180
+ _mint(recipients[i], totalSupply);
181
+ }
182
+ }
183
+
184
+ // Burn
185
+ function burn(uint256 tokenId) external {
186
+ require(_isApprovedOrOwner(msg.sender, tokenId), "NFT: not authorized");
187
+ _burn(tokenId);
188
+ }
189
+
190
+ // EIP-2981 Royalties
191
+ function royaltyInfo(uint256, uint256 salePrice) external view returns (address, uint256) {
192
+ uint256 royaltyAmount = (salePrice * royaltyBps) / 10000;
193
+ return (royaltyReceiver, royaltyAmount);
194
+ }
195
+
196
+ // Admin functions
197
+ function setBaseURI(string memory baseURI_) external onlyOwner {
198
+ _baseURI = baseURI_;
199
+ emit BaseURIUpdated(baseURI_);
200
+ }
201
+
202
+ function setTokenURI(uint256 tokenId, string memory _tokenURI) external onlyOwner {
203
+ require(_exists(tokenId), "NFT: nonexistent token");
204
+ _tokenURIs[tokenId] = _tokenURI;
205
+ }
206
+
207
+ function setMintPrice(uint256 _price) external onlyOwner {
208
+ mintPrice = _price;
209
+ }
210
+
211
+ function setMaxPerWallet(uint256 _max) external onlyOwner {
212
+ maxPerWallet = _max;
213
+ }
214
+
215
+ function toggleMinting(bool _enabled) external onlyOwner {
216
+ mintingEnabled = _enabled;
217
+ emit MintingToggled(_enabled);
218
+ }
219
+
220
+ function setWhitelistOnly(bool _whitelistOnly) external onlyOwner {
221
+ whitelistOnly = _whitelistOnly;
222
+ }
223
+
224
+ function updateWhitelist(address[] calldata accounts, bool status) external onlyOwner {
225
+ for (uint256 i = 0; i < accounts.length; i++) {
226
+ whitelist[accounts[i]] = status;
227
+ emit WhitelistUpdated(accounts[i], status);
228
+ }
229
+ }
230
+
231
+ function setRoyalty(address receiver, uint96 bps) external onlyOwner {
232
+ require(bps <= 1000, "NFT: royalty too high"); // Max 10%
233
+ royaltyReceiver = receiver;
234
+ royaltyBps = bps;
235
+ emit RoyaltyUpdated(receiver, bps);
236
+ }
237
+
238
+ function withdraw() external onlyOwner {
239
+ uint256 balance = address(this).balance;
240
+ require(balance > 0, "NFT: no balance");
241
+ payable(owner).transfer(balance);
242
+ }
243
+
244
+ function transferOwnership(address newOwner) external onlyOwner {
245
+ require(newOwner != address(0), "NFT: zero address");
246
+ emit OwnershipTransferred(owner, newOwner);
247
+ owner = newOwner;
248
+ }
249
+
250
+ // Internal functions
251
+ function _exists(uint256 tokenId) internal view returns (bool) {
252
+ return _owners[tokenId] != address(0);
253
+ }
254
+
255
+ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) {
256
+ address tokenOwner = ownerOf(tokenId);
257
+ return (spender == tokenOwner || getApproved(tokenId) == spender || isApprovedForAll(tokenOwner, spender));
258
+ }
259
+
260
+ function _mint(address to, uint256 tokenId) internal {
261
+ require(to != address(0), "NFT: mint to zero address");
262
+ require(!_exists(tokenId), "NFT: token exists");
263
+
264
+ _balances[to]++;
265
+ _owners[tokenId] = to;
266
+
267
+ emit Transfer(address(0), to, tokenId);
268
+ }
269
+
270
+ function _burn(uint256 tokenId) internal {
271
+ address tokenOwner = ownerOf(tokenId);
272
+
273
+ // Clear approvals
274
+ delete _tokenApprovals[tokenId];
275
+
276
+ _balances[tokenOwner]--;
277
+ delete _owners[tokenId];
278
+ delete _tokenURIs[tokenId];
279
+
280
+ emit Transfer(tokenOwner, address(0), tokenId);
281
+ }
282
+
283
+ function _transfer(address from, address to, uint256 tokenId) internal {
284
+ require(ownerOf(tokenId) == from, "NFT: not owner");
285
+ require(to != address(0), "NFT: transfer to zero address");
286
+
287
+ // Clear approvals
288
+ delete _tokenApprovals[tokenId];
289
+
290
+ _balances[from]--;
291
+ _balances[to]++;
292
+ _owners[tokenId] = to;
293
+
294
+ emit Transfer(from, to, tokenId);
295
+ }
296
+
297
+ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal {
298
+ _transfer(from, to, tokenId);
299
+ require(_checkOnERC721Received(from, to, tokenId, data), "NFT: transfer to non-receiver");
300
+ }
301
+
302
+ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private returns (bool) {
303
+ if (to.code.length > 0) {
304
+ try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (bytes4 retval) {
305
+ return retval == IERC721Receiver.onERC721Received.selector;
306
+ } catch {
307
+ return false;
308
+ }
309
+ }
310
+ return true;
311
+ }
312
+
313
+ function _toString(uint256 value) internal pure returns (string memory) {
314
+ if (value == 0) return "0";
315
+ uint256 temp = value;
316
+ uint256 digits;
317
+ while (temp != 0) {
318
+ digits++;
319
+ temp /= 10;
320
+ }
321
+ bytes memory buffer = new bytes(digits);
322
+ while (value != 0) {
323
+ digits--;
324
+ buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
325
+ value /= 10;
326
+ }
327
+ return string(buffer);
328
+ }
329
+
330
+ // ERC165
331
+ function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
332
+ return
333
+ interfaceId == 0x01ffc9a7 || // ERC165
334
+ interfaceId == 0x80ac58cd || // ERC721
335
+ interfaceId == 0x5b5e139f || // ERC721Metadata
336
+ interfaceId == 0x2a55205a; // ERC2981
337
+ }
338
+ }
@@ -0,0 +1,102 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.19;
3
+
4
+ /**
5
+ * @title QVTX Rewards Contract
6
+ * @dev Cross-chain rewards distribution for QVTX ecosystem
7
+ */
8
+ interface IERC20 {
9
+ function transfer(address to, uint256 amount) external returns (bool);
10
+ function transferFrom(address from, address to, uint256 amount) external returns (bool);
11
+ function balanceOf(address account) external view returns (uint256);
12
+ }
13
+
14
+ contract QVTXRewards {
15
+ address public owner;
16
+ address public rewardToken;
17
+
18
+ uint256 public rewardRate = 100; // Rewards per block
19
+ uint256 public lastUpdateBlock;
20
+ uint256 public rewardPerTokenStored;
21
+
22
+ mapping(address => uint256) public userRewardPerTokenPaid;
23
+ mapping(address => uint256) public rewards;
24
+ mapping(address => uint256) public stakes;
25
+
26
+ uint256 public totalStaked;
27
+
28
+ event Staked(address indexed user, uint256 amount);
29
+ event Withdrawn(address indexed user, uint256 amount);
30
+ event RewardPaid(address indexed user, uint256 reward);
31
+ event RewardRateUpdated(uint256 newRate);
32
+
33
+ modifier onlyOwner() {
34
+ require(msg.sender == owner, "Not owner");
35
+ _;
36
+ }
37
+
38
+ modifier updateReward(address account) {
39
+ rewardPerTokenStored = rewardPerToken();
40
+ lastUpdateBlock = block.number;
41
+ if (account != address(0)) {
42
+ rewards[account] = earned(account);
43
+ userRewardPerTokenPaid[account] = rewardPerTokenStored;
44
+ }
45
+ _;
46
+ }
47
+
48
+ constructor(address _rewardToken) {
49
+ owner = msg.sender;
50
+ rewardToken = _rewardToken;
51
+ lastUpdateBlock = block.number;
52
+ }
53
+
54
+ function rewardPerToken() public view returns (uint256) {
55
+ if (totalStaked == 0) {
56
+ return rewardPerTokenStored;
57
+ }
58
+ return rewardPerTokenStored +
59
+ ((block.number - lastUpdateBlock) * rewardRate * 1e18) / totalStaked;
60
+ }
61
+
62
+ function earned(address account) public view returns (uint256) {
63
+ return (stakes[account] * (rewardPerToken() - userRewardPerTokenPaid[account])) / 1e18
64
+ + rewards[account];
65
+ }
66
+
67
+ function stake(uint256 amount) external updateReward(msg.sender) {
68
+ require(amount > 0, "Cannot stake 0");
69
+ totalStaked += amount;
70
+ stakes[msg.sender] += amount;
71
+ IERC20(rewardToken).transferFrom(msg.sender, address(this), amount);
72
+ emit Staked(msg.sender, amount);
73
+ }
74
+
75
+ function withdraw(uint256 amount) external updateReward(msg.sender) {
76
+ require(amount > 0, "Cannot withdraw 0");
77
+ require(stakes[msg.sender] >= amount, "Insufficient stake");
78
+ totalStaked -= amount;
79
+ stakes[msg.sender] -= amount;
80
+ IERC20(rewardToken).transfer(msg.sender, amount);
81
+ emit Withdrawn(msg.sender, amount);
82
+ }
83
+
84
+ function claimReward() external updateReward(msg.sender) {
85
+ uint256 reward = rewards[msg.sender];
86
+ if (reward > 0) {
87
+ rewards[msg.sender] = 0;
88
+ IERC20(rewardToken).transfer(msg.sender, reward);
89
+ emit RewardPaid(msg.sender, reward);
90
+ }
91
+ }
92
+
93
+ function setRewardRate(uint256 _rate) external onlyOwner updateReward(address(0)) {
94
+ rewardRate = _rate;
95
+ emit RewardRateUpdated(_rate);
96
+ }
97
+
98
+ function emergencyWithdraw() external onlyOwner {
99
+ uint256 balance = IERC20(rewardToken).balanceOf(address(this));
100
+ IERC20(rewardToken).transfer(owner, balance);
101
+ }
102
+ }
@@ -0,0 +1,227 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.19;
3
+
4
+ /**
5
+ * @title QVTX Token
6
+ * @dev QuantVestrix native token with cross-chain capabilities
7
+ * @author QuantVestrix Tech Team (07-Tech)
8
+ */
9
+
10
+ import "./interfaces/IERC20.sol";
11
+ import "./interfaces/IERC20Metadata.sol";
12
+
13
+ contract QVTXToken is IERC20, IERC20Metadata {
14
+ string private constant _name = "QuantVestrix";
15
+ string private constant _symbol = "QVTX";
16
+ uint8 private constant _decimals = 18;
17
+
18
+ uint256 private _totalSupply;
19
+ address public owner;
20
+ address public bridgeContract;
21
+
22
+ mapping(address => uint256) private _balances;
23
+ mapping(address => mapping(address => uint256)) private _allowances;
24
+ mapping(address => bool) public minters;
25
+ mapping(address => bool) public blacklisted;
26
+
27
+ // Cross-chain tracking
28
+ mapping(uint256 => uint256) public chainSupply; // chainId => supply on that chain
29
+ uint256 public constant MAX_SUPPLY = 1_000_000_000 * 10**18; // 1 billion tokens
30
+
31
+ // Events
32
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
33
+ event MinterAdded(address indexed minter);
34
+ event MinterRemoved(address indexed minter);
35
+ event BridgeContractUpdated(address indexed newBridge);
36
+ event CrossChainMint(uint256 indexed sourceChain, address indexed to, uint256 amount);
37
+ event CrossChainBurn(uint256 indexed targetChain, address indexed from, uint256 amount);
38
+ event Blacklisted(address indexed account, bool status);
39
+
40
+ modifier onlyOwner() {
41
+ require(msg.sender == owner, "QVTX: caller is not owner");
42
+ _;
43
+ }
44
+
45
+ modifier onlyMinter() {
46
+ require(minters[msg.sender] || msg.sender == owner, "QVTX: caller is not minter");
47
+ _;
48
+ }
49
+
50
+ modifier onlyBridge() {
51
+ require(msg.sender == bridgeContract, "QVTX: caller is not bridge");
52
+ _;
53
+ }
54
+
55
+ modifier notBlacklisted(address account) {
56
+ require(!blacklisted[account], "QVTX: account is blacklisted");
57
+ _;
58
+ }
59
+
60
+ constructor(uint256 initialSupply) {
61
+ require(initialSupply <= MAX_SUPPLY, "QVTX: exceeds max supply");
62
+ owner = msg.sender;
63
+ _mint(msg.sender, initialSupply);
64
+ emit OwnershipTransferred(address(0), msg.sender);
65
+ }
66
+
67
+ // ERC20 Metadata
68
+ function name() external pure override returns (string memory) {
69
+ return _name;
70
+ }
71
+
72
+ function symbol() external pure override returns (string memory) {
73
+ return _symbol;
74
+ }
75
+
76
+ function decimals() external pure override returns (uint8) {
77
+ return _decimals;
78
+ }
79
+
80
+ // ERC20 Standard
81
+ function totalSupply() external view override returns (uint256) {
82
+ return _totalSupply;
83
+ }
84
+
85
+ function balanceOf(address account) external view override returns (uint256) {
86
+ return _balances[account];
87
+ }
88
+
89
+ function transfer(address to, uint256 amount) external override notBlacklisted(msg.sender) notBlacklisted(to) returns (bool) {
90
+ _transfer(msg.sender, to, amount);
91
+ return true;
92
+ }
93
+
94
+ function allowance(address tokenOwner, address spender) external view override returns (uint256) {
95
+ return _allowances[tokenOwner][spender];
96
+ }
97
+
98
+ function approve(address spender, uint256 amount) external override notBlacklisted(msg.sender) returns (bool) {
99
+ _approve(msg.sender, spender, amount);
100
+ return true;
101
+ }
102
+
103
+ function transferFrom(address from, address to, uint256 amount) external override notBlacklisted(from) notBlacklisted(to) returns (bool) {
104
+ uint256 currentAllowance = _allowances[from][msg.sender];
105
+ require(currentAllowance >= amount, "QVTX: insufficient allowance");
106
+ unchecked {
107
+ _approve(from, msg.sender, currentAllowance - amount);
108
+ }
109
+ _transfer(from, to, amount);
110
+ return true;
111
+ }
112
+
113
+ // Extended functions
114
+ function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
115
+ _approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue);
116
+ return true;
117
+ }
118
+
119
+ function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
120
+ uint256 currentAllowance = _allowances[msg.sender][spender];
121
+ require(currentAllowance >= subtractedValue, "QVTX: decreased allowance below zero");
122
+ unchecked {
123
+ _approve(msg.sender, spender, currentAllowance - subtractedValue);
124
+ }
125
+ return true;
126
+ }
127
+
128
+ // Minting & Burning
129
+ function mint(address to, uint256 amount) external onlyMinter {
130
+ require(_totalSupply + amount <= MAX_SUPPLY, "QVTX: exceeds max supply");
131
+ _mint(to, amount);
132
+ }
133
+
134
+ function burn(uint256 amount) external {
135
+ _burn(msg.sender, amount);
136
+ }
137
+
138
+ function burnFrom(address account, uint256 amount) external {
139
+ uint256 currentAllowance = _allowances[account][msg.sender];
140
+ require(currentAllowance >= amount, "QVTX: burn amount exceeds allowance");
141
+ unchecked {
142
+ _approve(account, msg.sender, currentAllowance - amount);
143
+ }
144
+ _burn(account, amount);
145
+ }
146
+
147
+ // Cross-chain functions
148
+ function bridgeMint(address to, uint256 amount, uint256 sourceChain) external onlyBridge {
149
+ require(_totalSupply + amount <= MAX_SUPPLY, "QVTX: exceeds max supply");
150
+ _mint(to, amount);
151
+ emit CrossChainMint(sourceChain, to, amount);
152
+ }
153
+
154
+ function bridgeBurn(address from, uint256 amount, uint256 targetChain) external onlyBridge {
155
+ _burn(from, amount);
156
+ emit CrossChainBurn(targetChain, from, amount);
157
+ }
158
+
159
+ // Admin functions
160
+ function transferOwnership(address newOwner) external onlyOwner {
161
+ require(newOwner != address(0), "QVTX: new owner is zero address");
162
+ emit OwnershipTransferred(owner, newOwner);
163
+ owner = newOwner;
164
+ }
165
+
166
+ function addMinter(address minter) external onlyOwner {
167
+ minters[minter] = true;
168
+ emit MinterAdded(minter);
169
+ }
170
+
171
+ function removeMinter(address minter) external onlyOwner {
172
+ minters[minter] = false;
173
+ emit MinterRemoved(minter);
174
+ }
175
+
176
+ function setBridgeContract(address _bridge) external onlyOwner {
177
+ bridgeContract = _bridge;
178
+ emit BridgeContractUpdated(_bridge);
179
+ }
180
+
181
+ function setBlacklist(address account, bool status) external onlyOwner {
182
+ blacklisted[account] = status;
183
+ emit Blacklisted(account, status);
184
+ }
185
+
186
+ // Internal functions
187
+ function _transfer(address from, address to, uint256 amount) internal {
188
+ require(from != address(0), "QVTX: transfer from zero address");
189
+ require(to != address(0), "QVTX: transfer to zero address");
190
+ require(_balances[from] >= amount, "QVTX: insufficient balance");
191
+
192
+ unchecked {
193
+ _balances[from] -= amount;
194
+ _balances[to] += amount;
195
+ }
196
+
197
+ emit Transfer(from, to, amount);
198
+ }
199
+
200
+ function _mint(address account, uint256 amount) internal {
201
+ require(account != address(0), "QVTX: mint to zero address");
202
+ _totalSupply += amount;
203
+ unchecked {
204
+ _balances[account] += amount;
205
+ }
206
+ emit Transfer(address(0), account, amount);
207
+ }
208
+
209
+ function _burn(address account, uint256 amount) internal {
210
+ require(account != address(0), "QVTX: burn from zero address");
211
+ require(_balances[account] >= amount, "QVTX: burn exceeds balance");
212
+
213
+ unchecked {
214
+ _balances[account] -= amount;
215
+ _totalSupply -= amount;
216
+ }
217
+
218
+ emit Transfer(account, address(0), amount);
219
+ }
220
+
221
+ function _approve(address tokenOwner, address spender, uint256 amount) internal {
222
+ require(tokenOwner != address(0), "QVTX: approve from zero address");
223
+ require(spender != address(0), "QVTX: approve to zero address");
224
+ _allowances[tokenOwner][spender] = amount;
225
+ emit Approval(tokenOwner, spender, amount);
226
+ }
227
+ }