I am writing Hardhat tests for a Solidity contract I've written. The contract contains a receive() external payable { ... } function. How can I call this from a hardhat test with an Ether amount?

1 Answer 1


You can make a transaction and send ether to the contract address

const [owner] = await ethers.getSigners();

const transactionHash = await owner.sendTransaction({
  to: "contract address",
  value: ethers.utils.parseEther("1.0"), // Sends exactly 1.0 ether

Making a transaction should call the receive function.

  • The BigNumber type from ethers.utils.parseEther("1") is an invalid type for the params. Using toHexString() also isn't working at the moment Jun 30, 2021 at 6:22
  • 1
    Thanks for letting me know, please see my updated answer.
    – trizin
    Jun 30, 2021 at 12:57
  • Excellent that worked! Jun 30, 2021 at 18:04
  • 2
    What method of the contract are you calling in the above answer? Aug 18, 2021 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.