File size: 1,259 Bytes
6fb9844
 
 
9e08a9a
6fb9844
9e08a9a
 
6fb9844
 
 
 
 
 
9e08a9a
 
6fb9844
 
 
 
 
 
 
 
 
 
 
9e08a9a
 
 
 
 
 
6fb9844
 
 
 
 
 
 
 
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
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);
  });