0

I have written the Ether Wallet Contract.

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

contract EtherWallet {
    address payable public owner;

    // solhint-disable-next-line no-empty-blocks
    receive() external payable {}

    constructor() {
        owner = payable(msg.sender);
    }

    function withdraw(uint256 _amount) external {
        require(msg.sender == owner, "Only owner withdraws");
        payable(msg.sender).transfer(_amount);
    }

    function getBalance() external view returns (uint256) {
        return address(this).balance;
    }
}

I want to test the withdraw function using waffle in hardhat. But the contract has no ether in it.

How can I send ether to this contract?

I have tried this answer, it did not work.

0

Your Answer

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

Browse other questions tagged or ask your own question.