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

Simplify single contract deployment #752

Open
16 tasks
kanej opened this issue May 2, 2024 · 0 comments
Open
16 tasks

Simplify single contract deployment #752

kanej opened this issue May 2, 2024 · 0 comments
Labels
status:needs-decision We need to make a decision about this

Comments

@kanej
Copy link
Member

kanej commented May 2, 2024

Ignition modules provide significant features (e.g. restartable deploys) but for the simplest case of deploying a single contract, it adds the boilerplate of declaring a module. Can we reduce/eliminate the boiler plate?

This is a design task to answer that question.

We need to support both script/test usage and command line usage.

Questions

  • How does this interact with module parameters?
  • Should we ignore the from field (and just rely on --default-sender)
  • How is the moduleId generated?
  • Can we rely on the default future id generation for the contract?
  • How are libraries to be supported? At the command line?
  • How are constructor args to be handled at the command line?
  • How does this work with create2?
  • How do we handle the tracking, from the user perspective of which contracts have been deployed?

Use Cases

  • Deploy a single Hardhat contract with no constructions args from a script/test by name and get back an ethers contract instance
  • Deploy a single Hardhat contract with no constructions args from a script/test by name and get back a viem contract instance
  • Deploy a single Hardhat contract with constructions args from a script/test by name and get back an ethers contract instance
  • Deploy a single Hardhat contract with constructions args from a script/test by name and get back a viem contract instance
  • Deploy a single Hardhat contract without constructor args by name from the cli
  • Deploy a single Hardhat contract with constructor args by name from the cli
  • Deploy a single contract with no constructor via create2 from script/test
  • Deploy a single contract resetting the deployment

Approach

From a scripts perspective maybe we enhance the ignition-helpers with a deployContract method:

const myToken = await hre.ignition.deployContract("Token", ["COIN", 10_000], { deploymentId: "my-sepolia-deploy-1" });
console.log(await myToken.getAddress())

This would be the equivalent of:

const { token: myToken } = await hre.ignition.deploy(buildModule("Contract-Token", (m) => m.contract("Token", ["COIN", 10_000])), { deploymentId: "my-sepolia-deploy-1" });
console.log(await myToken.getAddress())

In terms of the command line, perhaps we can leverage module parameters with a required property of constructor-args or something:

npx hardhat ignition deploy-contract MyToken --module-parameters "{\"constructor-args\": [\"COIN\", 10_000]}"
@kanej kanej added status:needs-decision We need to make a decision about this and removed status:triaging labels May 2, 2024
@kanej kanej moved this to Todo in Hardhat Ignition May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:needs-decision We need to make a decision about this
Projects
Status: Todo
Development

No branches or pull requests

1 participant