I created a smart contract with a constructor for sending and receiving I deployed the send contract with 2 ethers from the Remix VM (shanghai).. I then placed my ETH address from my Metamask wallet in the sendViaSend field and clicked the transact button the 1 ETH was withdrawn from the balance of the SendEther contract but the ether never appeared in Metamask?!?! Im wondering is it a factor where WEI is sent instead of ETH to the address and also is it mandatory that ether from Remix can only be sent to another smart contract instead of a regular ETH account on Metamask?

It compiled gave the green check I then deployed this from Remix VM(shanghai) with 2 ethers to the sendEther contract... I expected to send 1 ether to my metamask ETH wallet address...

Here is my code for the Send and Receive contract with constructor

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

// 3 ways to send ETH
// transfer - 2300 gass, reverts
// send - 2300 gas, returns bool
// call - all gas, returns bool and data


`contract SendEth {
    constructor() payable {}

    receive() external payable {}

    function sendViaTransfer(address payable _to) external payable {
        _to.transfer(123);
    }

    function sendViaSend(address payable _to) external payable {
        bool sent = _to.send(123);


        require(sent, "send failed");
    }

    function sendViaCall(address payable _to) external payable {
        (bool success, ) = _to.call{value: 123}("");
        require(success, "call failed");
    }
}

contract EthReceiver {
    event Log(uint amount, uint gas);

    receive() external payable {
        emit Log(msg.value, gasleft());
    }
}
0

There are 0 best solutions below