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

Request for Hardhat Deployment Example for TokenStake Contract #644

Open
terry1ee opened this issue May 7, 2024 · 1 comment
Open

Request for Hardhat Deployment Example for TokenStake Contract #644

terry1ee opened this issue May 7, 2024 · 1 comment

Comments

@terry1ee
Copy link

terry1ee commented May 7, 2024

Description

I am planning to deploy the TokenStake contract using Hardhat and would appreciate guidance on the recommended deployment procedure. I am particularly interested in understanding the best practices for deploying this contract with initializer functions and potential proxy setups for upgradability.

Request

Could you provide a detailed Hardhat deployment script example for the TokenStake contract? I am looking for guidance on:

  1. Proper handling of constructor and initializer parameters.
  2. Recommendations for setting up proxies if necessary for upgradability.
  3. Any specific Hardhat configurations or plugins that are recommended for this deployment.

This example will help ensure that I am implementing the deployment process correctly and leveraging the best practices you recommend.

Thank you for your support and assistance.

@terry1ee
Copy link
Author

terry1ee commented May 7, 2024

I tried to deploy using the following Hardhat Ignition script but encountered an error.

import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

const TokenStakeModule = buildModule("TokenStakeModule", (m) => {
  const nativeTokenWrapper = m.getParameter(
    "nativeTokenWrapper",
    "0xdf572718C075C93544F5624ebF7B26bBb85ca8CE"
  );
  const defaultAdmin = m.getParameter("defaultAdmin", m.getAccount(0));
  const contractURI = m.getParameter("contractURI", "ipfs://...");
  const trustedForwarders = m.getParameter("trustedForwarders", []);
  const rewardToken = m.getParameter(
    "rewardToken",
    "0xB3c3327A98a1F9b055b404F4b1629367d074C7eC"
  );
  const stakingToken = m.getParameter(
    "stakingToken",
    "0x6F0d766D99bf6007AF9364BEED348C177D877d82"
  );
  const timeUnit = m.getParameter("timeUnit", 60);
  const rewardRatioNumerator = m.getParameter("rewardRatioNumerator", 1);
  const rewardRatioDenominator = m.getParameter("rewardRatioDenominator", 10);

  const tokenStake = m.contract("TokenStake", [nativeTokenWrapper]);

  m.call(tokenStake, "initialize", [
    defaultAdmin,
    contractURI,
    trustedForwarders,
    rewardToken,
    stakingToken,
    timeUnit,
    rewardRatioNumerator,
    rewardRatioDenominator,
  ]);

  return { tokenStake };
});

export default TokenStakeModule;

error message

$ npx hardhat ignition deploy ./ignition/modules/TokenStake.ts --reset
Hardhat Ignition 🚀

Deploying [ TokenStakeModule ]

Batch #1
  Executed TokenStakeModule#TokenStake

Batch #2
  Failed TokenStakeModule#TokenStake.initialize

[ TokenStakeModule ] failed ⛔

Futures failed during execution:
 - TokenStakeModule#TokenStake.initialize: Simulating the transaction failed with error: Reverted with reason "Initializable: contract is already initialized"

To learn how to handle these errors: https://hardhat.org/ignition-errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant