>
>
Complete the 2023 Solidity Survey here
>
>

#Deploying your contracts

To deploy your contracts, you can use Hardhat Ignition, our declarative deployment system. You can find a sample Hardhat Ignition module inside the ignition/modules directory of the sample project:

TypeScript
JavaScript
import { buildModule } from "@nomicfoundation/hardhat-toolbox";

const currentTimestampInSeconds = Math.round(
  new Date(2023, 0, 1).valueOf() / 1000
);
const TEN_YEAR_IN_SECS: number = 10 * 365 * 24 * 60 * 60;
const TEN_YEARS_IN_FUTURE: number =
  currentTimestampInSeconds + TEN_YEAR_IN_SECS;

const ONE_GWEI: bigint = BigInt(hre.ethers.parseUnits("1", "gwei").toString());

const LockModule = buildModule("LockModule", (m) => {
  const unlockTime = m.getParameter("unlockTime", TEN_YEARS_IN_FUTURE);
  const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);

  const lock = m.contract("Lock", [unlockTime], {
    value: lockedAmount,
  });

  return { lock };
});

export default LockModule;

// ./ignition/LockModule.js
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");

const currentTimestampInSeconds = Math.round(new Date(2023, 0, 1) / 1000);
const TEN_YEAR_IN_SECS = 10 * 365 * 24 * 60 * 60;
const TEN_YEARS_IN_FUTURE = currentTimestampInSeconds + TEN_YEAR_IN_SECS;

const ONE_GWEI = BigInt(hre.ethers.parseUnits("1", "gwei"));

module.exports = buildModule("LockModule", (m) => {
  const unlockTime = m.getParameter("unlockTime", TEN_YEARS_IN_FUTURE);
  const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);

  const lock = m.contract("Lock", [unlockTime], {
    value: lockedAmount,
  });

  return { lock };
});

You can deploy in the localhost network following these steps:

  1. Start a local node

    npx hardhat node
    
  2. Open a new terminal and deploy the Hardhat Ignition module in the localhost network

    TypeScript
    JavaScript
    npx hardhat ignition deploy ./ignition/modules/LockModule.ts --network localhost
    
    npx hardhat ignition deploy ./ignition/modules/LockModule.js --network localhost
    

As general rule, you can target any network from your Hardhat config using:

npx hardhat ignition deploy ./ignition/modules/LockModule.js --network <your-network>

Alternatively, you can also deploy to an ephemeral instance of the Hardhat Network by running the command without the --network parameter:

npx hardhat ignition deploy ./ignition/modules/LockModule.js

Read more about Hardhat Ignition in the Ignition documentation.