smartcontractkit / full-blockchain-solidity-course-py

Ultimate Solidity, Blockchain, and Smart Contract - Beginner to Expert Full Course | Python Edition
MIT License
10.79k stars 2.9k forks source link

Lesson 6: Constructor requires no arguments #794

Open Jaqck opened 2 years ago

Jaqck commented 2 years ago

Completing lesson 6 and I run into an error I am unable to solve. After reaching the mocks section where I would be generating a mock address I started to receive the error message:

TypeError: constructor requires no arguments

I have looked this up and I am unable to find out the cause of this. if I remove the mock code and go back a few steps it works correctly. I also tried to copy the completed lesson code and this returns the same error.

Is it due to this line in the deploy_mocks.py file?

MockV3Aggregator.deploy(DECIMALS, INITIAL_VALUE, {"from": account})

any help would be great!

Jaqck commented 2 years ago

I have continued to test this. I had an error where the "@Chainlink" imports were showing as red and not importing correctly (even after following the remapping on the video). I thought this may be adding to the constructor error. to test this I just created my own Aggregator. Sol files and imported those locally. This removed the red error on the @chainlink sections but still returned the constructor requires no arguments.

huynhnhathao commented 2 years ago

No, I don't think

MockV3Aggregator.deploy(DECIMALS, INITIAL_VALUE, {"from": account}) is the problem, because the MockV3Aggregator contract's constructor requires two arguments,

constructor(uint8 _decimals, int256 _initialAnswer) public { decimals = _decimals; updateAnswer(_initialAnswer); }

But your error was TypeError: constructor requires no arguments, can you check again your MockV3Aggregator's constructor? or maybe you were deploying a different contract?

Jaqck commented 2 years ago

My MockV3Aggregator code is exactly the same as the example (I removed my original code and imported the code from git hub to trouble shoot) I think the error comes when using the deploy_fund_me function but I am unsure.

br0wnD3v commented 2 years ago

Can you please share your FundMe.sol, the relevant python files and the config file?

cromewar commented 2 years ago

Any advances on this @Jaqck ?

kjones86 commented 2 years ago

I am looking for a solution to this error myself....

kjones86 commented 2 years ago

Oops! When you copied the code from github to your contract, you most likely forgot to update the constructor in the Fundme.sol so the address is not hard coded to only work with the rinkeby chain. I made that change and everything is deploying fine now.