I try to transfer ether from one contract B to contract A. But I get "Transaction mined but execution failed"
Code:
pragma solidity ^0.5.0;
contract A {
address payable public owner;
uint public block_number;
constructor () public payable {
owner = msg.sender;
}
function getBalance () public view returns (uint) {
return address(this).balance;
}
function () external payable {
block_number = block.number;
}
}
contract B {
address payable public owner;
address payable public contract_a = 0x600F51a64e8A703b759EB3d735132d6C802A0a7b; //contract's A address after deploy
constructor () public payable {
owner = msg.sender;
}
function () external payable {
contract_a.transfer(msg.value);
}
}
At first I deploy A and copy and paste address to B. Then I send ether from wallet to B and get error. What am I doing wrong? If I send ether from wallet directly to A it's successful.