I have two smart contracts. A caller and a receiver.
My caller code looks like so:
// SPDX-License-Identifier: G.P.L 3.0
pragma solidity 0.8.3;
contract Caller {
event Response(bool success, bytes data);
function testCallFoo(address payable _addr) public payable {
// You can send ether and specify a custom gas amount
(bool success, bytes memory data) = _addr.call{value: msg.value, gas: 50000}(
abi.encodeWithSignature("foo(string,uint256)", "call foo", 123)
);
emit Response(success, data);
}
function testNotThere(address payable _addr) public payable {
// You can send ether and specify a custom gas amount
(bool success, bytes memory data) = _addr.call{value: msg.value, gas: 50000}("");
emit Response(success, data);
}
}
and my receiver code looks like so:
contract Receiver {
// 'empty' with no code inside it.
}
How can I send ether to the receiver contract? Is it possible? If no, why? Yet the contract is an address on the blockchain?
What is the minimum code required to send ether to a contract?
I am asking all this to understand what it takes for a contract to be able to receive ether.