Skip to content

Conversation

yoyoj1023
Copy link
Contributor

fix: add missing constructor parameter to Counter contract deployment

Description

Fixed the missing constructor parameter issue when deploying the Counter contract in packages/hardhat/test/Counter.ts.

Problem:
The original test code was deploying the Counter contract without providing the required constructor parameter:

counter = (await counterFactory.deploy()) as Counter;

Solution:
After examining the Counter.sol contract's constructor, it requires a uint _x parameter to initialize the state variable x:

constructor(uint _x) {
    x = _x;
}

Therefore, added the initial value parameter 10 in the test deployment:

counter = (await counterFactory.deploy(10)) as Counter;

This fix ensures that the test can execute properly and the contract is deployed with an appropriate initial value.

Additional Information

Related Issues

Note: This is a small and straightforward bug fix that resolves a deployment parameter mismatch between the contract constructor and test deployment call.

Your ENS/address:
0xdb4101e7f5E2cC0e1A749092ff5287e3d36A5df6

fix: the parameter of deploy in Counter.ts
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

Successfully merging this pull request may close these issues.

1 participant