Ethereum: TypeError: Cannot read properties of undefined (reading ‘parseEther’)
I can help. However, I have to emphasize that the most secure fraction of the code contains some syntax errors and possible problems.
Here is an updated version of the article:
Ethereum: TypeError cannot read indefinite qualities
If Ethereum works with smart contracts through Hardhat, it is important to handle possible errors in the implementation of the contract. One of the most common problems that may arise is to try to achieve the characteristics of an object that is not properly initialized.
In this case, we come to the type and try to call the object “Parsether ()”. This error occurs because the “deposit” object is not configured or initialized before trying to use it.
Let’s see what can cause this question:
`Javascript
Const {Ethers} = ASK ("Hardhat");
Const {time} = ASK ("@demicfoundation/hardhat-network-helPers");
Describes ("transaction", functions () {
Deposited;
Deposited;
pre (async () => {{{
// initialize the transaction agreement using Hardhat ContractFactory API
Const -SconconcTFactory = Waiting for the Ethers.getConsChctionFactory ("transaction");
Transaction = wait for the deposit to deposit to let the teticontractractory.deploy ();
Wait for the deposit .constructor ();
// Set the transaction address as an environmental variable for easy access
Process.env.Secrow_contract_address = Wait for the deposit.
// Set both transaction agreements of the event, both of the features of the event
CONST deposit deposit = [
{{
Inputs: [],
StateChanges: [],
Payable: False,
Return: []
}
];
Const Eventfunctions = ["LetKrowescrow", "Letkrowpay"];
// Call the placement method to initialize the transaction agreement
Expected new Ethers.Contract (ScrowConcTractaddress, Escrowabi, Scrowcontract.abi) (process.env.secrow_contract_address);
});
IT ("correctly check the functionality of the transaction", async functions () {
Const deposit = expect this.
// ... the rest of the code
There are changes here to solve the problem:
- They added a “Scrowcontractaddress” variable and initialized with the title of the Agreement.
- Before use, it is called “placement” in the ScrowContract class, ensuring proper initialization of the contract.
- Set the “secrow_contract_address” environmental variable to save the title of the transaction agreement.
To eliminate the problem and solve the code base:
`Javascript
Const {Ethers} = ASK ("Hardhat");
Describes ("transaction", functions () {
Deposited;
Deposited;
pre (async () => {{{
CONST SCROWCONTRACTADDRESS = "0X ..."; // Replace the actual address of the agreement at your disposal.
Transaction = Waiting for Ethers.getCrectionFactory ("transaction");
Transaction = wait for deposit.dloy (scrowcontractaddress);
Wait for the deposit .constructor ();
Process.env.Secrow_contract_address = scrow.address;
});
IT ("correctly check the functionality of the transaction", async functions () {
Const deposit = wait for this.
// ... the rest of the code
In this updated version, a solid core “process has been replaced.