Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create deploy.ts #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions hardhat/scripts/old_as_examples/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ethers } from "hardhat";
import { Lottery__factory } from "../typechain-types";
import * as dotenv from "dotenv";
dotenv.config();

const PURCHASE_RATIO = 1;
const BET_PRICE = 1;
const BET_FEE = 0.1;

async function main() {
const infuraProvider = new ethers.providers.InfuraProvider("goerli", process.env.INFURA_API_KEY);
const signer = new ethers.Wallet(process.env.PRIVATE_KEY ?? "").connect(infuraProvider);

const lotteryContractFactory = new Lottery__factory(signer);
const lotteryContract = await lotteryContractFactory.deploy(
PURCHASE_RATIO,
ethers.utils.parseEther(BET_PRICE.toFixed(18)),
ethers.utils.parseEther(BET_FEE.toFixed(18))
);
await lotteryContract.deployed();

const paymentTokenAddress = await lotteryContract.paymentToken();
const paymentTokenFactory = await ethers.getContractFactory("LotteryToken");
const paymentToken = paymentTokenFactory.attach(paymentTokenAddress);

console.log(`The lottery contract has been deployed at address ${lotteryContract.address}`);
console.log(`The payment token contract has been deployed at address ${paymentToken.address}`);
}

main().catch((err) => {
console.error(err);
process.exit(1);
});