|
1 | | -import { HardhatRuntimeEnvironment } from "hardhat/types"; |
2 | | -import { DeployFunction } from "hardhat-deploy/types"; |
3 | | -import { DEX } from "../typechain-types/contracts/DEX"; |
4 | | -import { Balloons } from "../typechain-types/contracts/Balloons"; |
| 1 | +import { artifacts, deployScript } from "../rocketh/deploy.js"; |
5 | 2 |
|
6 | 3 | /** |
7 | | - * Deploys a contract named "YourContract" using the deployer account and |
8 | | - * constructor arguments set to the deployer address |
| 4 | + * Deploys "Balloons" and "DEX". |
9 | 5 | * |
10 | | - * @param hre HardhatRuntimeEnvironment object. |
| 6 | + * On localhost, the deployer account is the one that comes with Hardhat, which is already funded. |
| 7 | + * |
| 8 | + * When deploying to live networks (e.g `yarn deploy --network sepolia`), the deployer account |
| 9 | + * should have sufficient balance to pay for the gas fees for contract creation. |
| 10 | + * |
| 11 | + * You can generate a random account with `yarn generate` which will fill DEPLOYER_PRIVATE_KEY_ENCRYPTED |
| 12 | + * in the .env file (used in hardhat.config.ts). |
| 13 | + * Run `yarn account` to check the deployer balance on every network. |
11 | 14 | */ |
12 | | -const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { |
13 | | - /* |
14 | | - On localhost, the deployer account is the one that comes with Hardhat, which is already funded. |
15 | | -
|
16 | | - When deploying to live networks (e.g `yarn deploy --network sepolia`), the deployer account |
17 | | - should have sufficient balance to pay for the gas fees for contract creation. |
18 | | -
|
19 | | - You can generate a random account with `yarn generate` which will fill DEPLOYER_PRIVATE_KEY |
20 | | - with a random private key in the .env file (then used on hardhat.config.ts) |
21 | | - You can run the `yarn account` command to check your balance in every network. |
22 | | - */ |
23 | | - const { deployer } = await hre.getNamedAccounts(); |
24 | | - const { deploy } = hre.deployments; |
25 | | - |
26 | | - await deploy("Balloons", { |
27 | | - from: deployer, |
28 | | - // Contract constructor arguments |
29 | | - //args: [deployer], |
30 | | - log: true, |
31 | | - // autoMine: can be passed to the deploy function to make the deployment process faster on local networks by |
32 | | - // automatically mining the contract deployment transaction. There is no effect on live networks. |
33 | | - autoMine: true, |
34 | | - }); |
35 | | - // Get the deployed contract |
36 | | - // const yourContract = await hre.ethers.getContract("YourContract", deployer); |
37 | | - const balloons: Balloons = await hre.ethers.getContract("Balloons", deployer); |
38 | | - const balloonsAddress = await balloons.getAddress(); |
39 | | - |
40 | | - await deploy("DEX", { |
41 | | - from: deployer, |
42 | | - // Contract constructor arguments |
43 | | - args: [balloonsAddress], |
44 | | - log: true, |
45 | | - // autoMine: can be passed to the deploy function to make the deployment process faster on local networks by |
46 | | - // automatically mining the contract deployment transaction. There is no effect on live networks. |
47 | | - autoMine: true, |
48 | | - }); |
49 | | - |
50 | | - const dex = (await hre.ethers.getContract("DEX", deployer)) as DEX; |
51 | | - |
52 | | - // // CHECKPOINT 2: Paste in your front-end address here to get 10 balloons on deploy: |
53 | | - // await balloons.transfer("YOUR_FRONTEND_ADDRESS", "" + 10 * 10 ** 18); |
54 | | - |
55 | | - // // CHECKPOINT 3: Uncomment to init DEX on deploy: |
56 | | - // const dexAddress = await dex.getAddress(); |
57 | | - // console.log("Approving DEX (" + dexAddress + ") to take Balloons from main account..."); |
58 | | - // // If you are going to the testnet make sure your deployer account has enough ETH |
59 | | - // await balloons.approve(dexAddress, hre.ethers.parseEther("100")); |
60 | | - // console.log("INIT exchange..."); |
61 | | - // await dex.init(hre.ethers.parseEther("5"), { |
62 | | - // value: hre.ethers.parseEther("5"), |
63 | | - // gasLimit: 200000, |
64 | | - // }); |
65 | | -}; |
66 | | - |
67 | | -export default deployYourContract; |
68 | | - |
69 | | -// Tags are useful if you have multiple deploy files and only want to run one of them. |
70 | | -// e.g. yarn deploy --tags YourContract |
71 | | -deployYourContract.tags = ["Balloons", "DEX"]; |
| 15 | +export default deployScript( |
| 16 | + async ({ deploy, namedAccounts }) => { |
| 17 | + const { deployer } = namedAccounts; |
| 18 | + |
| 19 | + const balloons = await deploy("Balloons", { |
| 20 | + account: deployer, |
| 21 | + artifact: artifacts.Balloons, |
| 22 | + args: [], |
| 23 | + }); |
| 24 | + |
| 25 | + await deploy("DEX", { |
| 26 | + account: deployer, |
| 27 | + artifact: artifacts.DEX, |
| 28 | + args: [balloons.address], |
| 29 | + }); |
| 30 | + |
| 31 | + // // CHECKPOINT 2: Paste in your front-end address here to get 10 balloons on deploy: |
| 32 | + // await execute(balloons, { functionName: "transfer", args: ["YOUR_FRONTEND_ADDRESS", parseEther("10")], account: deployer }); |
| 33 | + |
| 34 | + // // CHECKPOINT 3: Uncomment to init DEX on deploy: |
| 35 | + // console.log("Approving DEX (" + dex.address + ") to take Balloons from main account..."); |
| 36 | + // await execute(balloons, { functionName: "approve", args: [dex.address, parseEther("100")], account: deployer }); |
| 37 | + // console.log("INIT exchange..."); |
| 38 | + // await execute(dex, { functionName: "init", args: [parseEther("5")], value: parseEther("5"), account: deployer }); |
| 39 | + }, |
| 40 | + // Tags are useful if you have multiple deploy files and only want to run one of them. |
| 41 | + // e.g. yarn deploy --tags DEX |
| 42 | + { tags: ["Balloons", "DEX"] }, |
| 43 | +); |
0 commit comments