const hre = require("hardhat");
async function main() {
console.log("Testing balance checks on cyberia.my/ganache...\n");
const provider = hre.ethers.provider;
console.log("1. Testing network connection:");
try {
const network = await provider.getNetwork();
console.log(` โ Connected to chain ID: ${network.chainId}`);
const blockNumber = await provider.getBlockNumber();
console.log(` โ Current block number: ${blockNumber}`);
} catch (error) {
console.log(` โ Network connection failed: ${error.message}`);
return;
}
console.log("\n2. Testing ERC20 contract:");
const erc20Address = "0xf6292eE7F9d03BA5844666DD4981d8b38b8d598d";
try {
const ERC20 = await hre.ethers.getContractAt(
"MockUSDT",
erc20Address,
);
const name = await ERC20.name();
const symbol = await ERC20.symbol();
const decimals = await ERC20.decimals();
const totalSupply = await ERC20.totalSupply();
console.log(` โ Contract found at ${erc20Address}`);
console.log(` โ Name: ${name}`);
console.log(` โ Symbol: ${symbol}`);
console.log(` โ Decimals: ${decimals}`);
console.log(
` โ Total Supply: ${hre.ethers.formatUnits(totalSupply, decimals)}`,
);
} catch (error) {
console.log(` โ ERC20 contract check failed: ${error.message}`);
return;
}
console.log("\n3. Testing balance check for random address:");
const testAddress = "0xb402FD4dA064Ce84c92B1AA57DaB01faB5aFE82C"; try {
const ERC20 = await hre.ethers.getContractAt(
"MockUSDT",
erc20Address,
);
const balance = await ERC20.balanceOf(testAddress);
const decimals = await ERC20.decimals();
console.log(` โ Address: ${testAddress}`);
console.log(
` โ ERC20 Balance: ${hre.ethers.formatUnits(balance, decimals)}`,
);
const ethBalance = await provider.getBalance(testAddress);
console.log(` โ ETH Balance: ${hre.ethers.formatEther(ethBalance)}`);
} catch (error) {
console.log(` โ Balance check failed: ${error.message}`);
return;
}
console.log("\n4. Testing EventManager contract:");
const eventManagerAddress = "0xadA1E7CCA885304914d1857637A67A9E611474AF";
try {
const EventManager = await hre.ethers.getContractAt(
"CyberValleyEventManager",
eventManagerAddress,
);
const decimals = 6;
console.log(` โ Contract found at ${eventManagerAddress}`);
console.log(" โ Event request fee is per-place deposit (eventDepositSize)");
} catch (error) {
console.log(` โ EventManager contract check failed: ${error.message}`);
}
console.log("\nโ All basic checks passed!");
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});