Commit before cuna
This commit is contained in:
65
scripts/deploy_bot_manager_sonic.js
Normal file
65
scripts/deploy_bot_manager_sonic.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const { ethers } = require("hardhat");
|
||||
|
||||
async function main() {
|
||||
console.log("🤖 Deploying PacaBotManager on Sonic Network");
|
||||
console.log("============================================");
|
||||
|
||||
const [deployer] = await ethers.getSigners();
|
||||
console.log(`📍 Deploying from account: ${deployer.address}`);
|
||||
console.log(`💰 Account balance: ${ethers.formatEther(await deployer.provider.getBalance(deployer.address))} SONIC`);
|
||||
|
||||
// Get current gas price and add small buffer
|
||||
const gasPrice = await deployer.provider.getFeeData();
|
||||
console.log(`⛽ Current gas price: ${ethers.formatUnits(gasPrice.gasPrice, "gwei")} gwei`);
|
||||
|
||||
// Deploy PacaBotManager
|
||||
console.log("\n🚀 Deploying PacaBotManager contract...");
|
||||
const BotManagerFactory = await ethers.getContractFactory("PacaBotManager");
|
||||
|
||||
const botManager = await BotManagerFactory.deploy({
|
||||
gasPrice: gasPrice.gasPrice, // Use current network gas price
|
||||
});
|
||||
|
||||
console.log("⏳ Waiting for deployment transaction to be mined...");
|
||||
await botManager.waitForDeployment();
|
||||
|
||||
const botManagerAddress = await botManager.getAddress();
|
||||
console.log(`✅ PacaBotManager deployed successfully!`);
|
||||
console.log(`📍 Contract address: ${botManagerAddress}`);
|
||||
|
||||
// Get deployment transaction details
|
||||
const deployTx = botManager.deploymentTransaction();
|
||||
console.log(`🧾 Deployment transaction: ${deployTx.hash}`);
|
||||
console.log(`⛽ Gas used: ${deployTx.gasLimit.toString()}`);
|
||||
|
||||
// Verify owner is set correctly
|
||||
console.log("\n🔍 Verifying deployment...");
|
||||
try {
|
||||
const owner = await botManager.owner();
|
||||
console.log(`👤 Contract owner: ${owner}`);
|
||||
console.log(`✅ Owner matches deployer: ${owner.toLowerCase() === deployer.address.toLowerCase()}`);
|
||||
} catch (error) {
|
||||
console.log(`⚠️ Could not verify owner: ${error.message}`);
|
||||
}
|
||||
|
||||
console.log("\n📋 Deployment Summary");
|
||||
console.log("====================");
|
||||
console.log(`🤖 PacaBotManager: ${botManagerAddress}`);
|
||||
console.log(`👤 Owner: ${deployer.address}`);
|
||||
console.log(`🌐 Network: Sonic`);
|
||||
console.log(`🧾 Transaction: ${deployTx.hash}`);
|
||||
console.log("\n💡 Next steps:");
|
||||
console.log("1. Verify the contract on SonicScan (optional)");
|
||||
console.log("2. Authorize the bot manager on your PACA contracts");
|
||||
console.log("3. Test the clearStakes functionality");
|
||||
|
||||
console.log("\n🔗 SonicScan URL:");
|
||||
console.log(` https://sonicscan.org/address/${botManagerAddress}`);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error("💥 Deployment failed:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user