const hre = require("hardhat"); async function main() { const networkName = hre.network.name; const [deployer] = await hre.ethers.getSigners(); console.log(`Deploying to network: ${networkName}`); console.log("Deploying contracts with account:", deployer.address); const Voting = await hre.ethers.getContractFactory("Voting"); const voting = await Voting.deploy(); await voting.waitForDeployment(); const contractAddress = await voting.getAddress(); console.log("Voting contract deployed to:", contractAddress); // Create a sample poll for demo console.log("Creating sample poll..."); const tx = await voting.createPoll( "Favorite Blockchain Technology", "Vote for your favorite blockchain platform. This poll will demonstrate the voting system.", ["Ethereum", "Solana", "Bitcoin", "Polkadot", "Cardano"], 60 // 60 minutes ); await tx.wait(); console.log("Sample poll created!"); console.log("\nUse this in your app env:"); console.log(`NEXT_PUBLIC_CONTRACT_ADDRESS=${contractAddress}`); if (networkName === "sepolia") { console.log("NEXT_PUBLIC_ONCHAIN_CHAIN_ID=11155111"); } } main() .then(() => process.exit(0)) .catch((error) => { console.error(error); process.exit(1); });