0
pragma solidity ^0.5.0;

contract Contract1 {

  address payable owner;
  uint public value;

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

  function() external payable {

    value = msg.value;

  }


}


contract Contract2{

    Contract1 public c;

    function setContract(address payable _addr) public{

     c = Contract1(_addr);

    }

    function() external payable{



    }

    function sendEther() public payable{

        address(c).transfer(msg.value);

    }



}

Whenever I try to call the sendEther() I get the following error

transact to Contract2.sendEther errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

Hackeerrrr
  • 43
  • 6
  • https://ethereum.stackexchange.com/questions/15953/send-ethers-from-one-contract-to-another#17378 – metmirr Feb 07 '20 at 07:53
  • If I try sending using send(), it shows a warning but still no ether is being transfered – Hackeerrrr Feb 07 '20 at 08:55
  • 1
    The fallback function uses more gas than the gas stipend of 2300. The recommended solution is to explicitly invoke a payable function instead. – Ismael Feb 07 '20 at 16:02
  • I have considered that solution as well but I want to experiment on sending ethers to SCs which have a default fallback function. I am new to SC development and so I am trying to learn these things. Pardon if it is stupid or too trival – Hackeerrrr Feb 10 '20 at 07:18

0 Answers0