The code is as following, if Contract send ether to Contract Receiver, I will recevice: transact to Sender.send errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value.
However, if I annotate line "addr = msg.sender;" "amount = msg.value;" everything is ok, and I will receive the event log
pragma solidity ^0.4.11;
contract Receiver {
address public addr;
uint public amount;
event log(address, uint);
function() payable{
addr = msg.sender;
amount = msg.value;
log(msg.sender, msg.value);
}
function Receiver() public payable {
addr = msg.sender;
amount = msg.value;
}
}
contract Sender{
function send(address addr, uint amount) payable{
addr.transfer(amount);
}
function getBalance() payable returns (uint) {
return this.balance;
}
function Sender() payable{ }
}