Reputation: 83
I am developing a smart contract with solidity(version 0.8.0) at buildspace here is my code snippet in TypeScript(4.5.x)/JavaScript, and node 16.13.x
...
const waveContractFactory = await hre.ethers.getContractFactory("WavePortal");
const waveContract = await waveContractFactory.deploy({
value: hre.ethers.utils.parseEther("0.1"),
});
...
The above code is written in a file called: run.ts
To execute the code, this is the command:
npx hardhat run scripts/run.ts
Here is the head of the error I got with its tail truncated:
error TS2345: Argument of type '{ value: BigNumber; }' is not assignable to parameter of type 'Overrides & { from?: string | Promise<string> | undefined; }'.
Object literal may only specify known properties, and 'value' does not exist in type 'Overrides & { from?: string | Promise<string> | undefined; }'.
7 value: hre.ethers.utils.parseEther("0.1"),
....
with "7" above showing the line where the error occurred.
I didn't know where the error is coming from. The code keeps failing for run.ts/js
I am trying to fund my smart contract with 0.1 ether.
Here is the snippet to my smart contract:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "hardhat/console.sol";
contract WavePortal {
...
constructor() {
console.log("Hello, Multiverse... I am Smart Contract WavePortal");
}
...
}
Upvotes: 2
Views: 4345
Reputation: 83
So after making research for some hours, I found the answer here.
I had to add a payable
modifier to the contract's constructor and it work:
contract WavePortal {
...
constructor() payable {
console.log("Hello, Multiverse... I am Smart Contract WavePortal");
}
...
}
Upvotes: 4