forked from PogungDev/coreliquid-master
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-real-wallet.js
More file actions
124 lines (102 loc) Β· 5.31 KB
/
test-real-wallet.js
File metadata and controls
124 lines (102 loc) Β· 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
require('dotenv').config();
const { ethers } = require('ethers');
// Contract ABI for SimpleToken
const SimpleTokenABI = [
"function name() view returns (string)",
"function symbol() view returns (string)",
"function decimals() view returns (uint8)",
"function totalSupply() view returns (uint256)",
"function balanceOf(address) view returns (uint256)",
"function transfer(address to, uint256 amount) returns (bool)",
"function mint(address to, uint256 amount)",
"function burn(uint256 amount)",
"event Transfer(address indexed from, address indexed to, uint256 value)"
];
async function testRealWallet() {
console.log('π§ͺ CoreLiquid Protocol - Real Wallet Testing');
console.log('============================================\n');
const privateKey = process.env.PRIVATE_KEY;
const rpcUrl = process.env.CORE_TESTNET_RPC_URL || 'https://rpc.test2.btcs.network';
const coreTokenAddress = '0x162ff7e6202d6765290E58932EABA20Cc26939AF';
const btcTokenAddress = '0x5b3578d284bEbcb15037567A49Ce855A636fff4E';
try {
// Connect to Core Testnet
const provider = new ethers.JsonRpcProvider(rpcUrl);
const wallet = new ethers.Wallet(privateKey, provider);
console.log('π Connected to Core Testnet');
console.log('Wallet Address:', wallet.address);
// Check wallet balance
const balance = await provider.getBalance(wallet.address);
console.log('Wallet Balance:', ethers.formatEther(balance), 'tCORE\n');
// Connect to contracts
const coreToken = new ethers.Contract(coreTokenAddress, SimpleTokenABI, wallet);
const btcToken = new ethers.Contract(btcTokenAddress, SimpleTokenABI, wallet);
// Test CORE Token
console.log('πͺ Testing CORE Token Contract');
console.log('==============================');
const coreName = await coreToken.name();
const coreSymbol = await coreToken.symbol();
const coreDecimals = await coreToken.decimals();
const coreTotalSupply = await coreToken.totalSupply();
const coreBalance = await coreToken.balanceOf(wallet.address);
console.log('Name:', coreName);
console.log('Symbol:', coreSymbol);
console.log('Decimals:', coreDecimals);
console.log('Total Supply:', ethers.formatEther(coreTotalSupply));
console.log('Your Balance:', ethers.formatEther(coreBalance), coreSymbol);
// Test BTC Token
console.log('\nβΏ Testing BTC Token Contract');
console.log('=============================');
const btcName = await btcToken.name();
const btcSymbol = await btcToken.symbol();
const btcDecimals = await btcToken.decimals();
const btcTotalSupply = await btcToken.totalSupply();
const btcBalance = await btcToken.balanceOf(wallet.address);
console.log('Name:', btcName);
console.log('Symbol:', btcSymbol);
console.log('Decimals:', btcDecimals);
console.log('Total Supply:', ethers.formatUnits(btcTotalSupply, btcDecimals));
console.log('Your Balance:', ethers.formatUnits(btcBalance, btcDecimals), btcSymbol);
// Test real transaction - Transfer small amount to self
console.log('\nπ Testing Real Transaction');
console.log('============================');
const transferAmount = ethers.parseEther('1'); // 1 CORE token
console.log('Transferring 1 CORE token to self...');
const tx = await coreToken.transfer(wallet.address, transferAmount);
console.log('Transaction Hash:', tx.hash);
console.log('Explorer Link:', `https://scan.test.btcs.network/tx/${tx.hash}`);
console.log('β³ Waiting for confirmation...');
const receipt = await tx.wait();
console.log('β
Transaction confirmed in block:', receipt.blockNumber);
// Check balance after transfer
const newCoreBalance = await coreToken.balanceOf(wallet.address);
console.log('New CORE Balance:', ethers.formatEther(newCoreBalance), 'CORE');
console.log('\nπ Real Wallet Testing Completed Successfully!');
console.log('===============================================');
console.log('β
Smart contracts are working');
console.log('β
Real transactions are successful');
console.log('β
Ready for UI/UX testing');
console.log('\nπ Next Steps for UI/UX Testing:');
console.log('1. Start frontend: npm run dev');
console.log('2. Connect your wallet (MetaMask/WalletConnect)');
console.log('3. Switch to Core Testnet (Chain ID: 1114)');
console.log('4. Test token interactions through UI');
console.log('5. Verify transactions on explorer');
return {
success: true,
contracts: {
coreToken: coreTokenAddress,
btcToken: btcTokenAddress
},
transactionHash: tx.hash,
blockNumber: receipt.blockNumber
};
} catch (error) {
console.error('\nβ Testing failed:', error.message);
return { success: false, error: error.message };
}
}
if (require.main === module) {
testRealWallet();
}
module.exports = { testRealWallet };