0

I am using ganache to create 10 ethereum accounts. I want to transfer ethereum from one account to a smart contract. I am doing this by writing two following smart contracts in solidity;

pragma solidity >=0.4.0 <0.6.0;
contract Ether_Transfer_To{
    function () external payable { //fallback function

    }
    function get_balance() public returns(uint){
        return address(this).balance;
    }
}
contract Ether_Transfer_From{
    Ether_Transfer_To private the_instance;
    constructor() public{
        //the_instance=Ether_Transfer_To(address(this));
        the_instance=new Ether_Transfer_To();
    }
    function get_balance() public returns(uint){
        return address(this).balance;
    }
    function get_balance_of_instance() public returns(uint){
        //return address(the_instance).balance;
        return the_instance.get_balance();
    }
    function () external payable {
        // msg.sender.send(msg.value)
        address(the_instance).send(msg.value);
    }
}

When I deploy the contract Ether_Transfer_From smart contract then I get its three-member functions as follows in remix;

enter image description here

But when I sent one 1 Wei from account to smart contract by writing 1 in the text box and clicking on a (fallback) button, then I get the following error;

transact to Ether_Transfer_From. (fallback) errored: VM Exception while processing transaction: out of gas

I followed the answer of the same question by installing Ganache-cli 7.0.0 beta.0 by using following command;

npm install -g ganache-cli@7.0.0-beta.0

But I still get the same error. I think I am using older Ganache cli instead of Ganache-cli 7.0.0 beta.0 as it goes to C drive and I installed ganache 2.1.1 in D drive previously.

I just want to send ethereum from one account to other but I am really stuck in this out of gas Error. If there is any way to remove this error or transfer ethereum from one account to another then please let me know.

  • Your code works fine for me on Remix, using the JavaScript VM and Solidity compiler version 0.5.11+commit.c082d0b4, so presumably the issue is with Ganache. – user19510 Sep 15 at 16:59
  • Yes i know that there is issue with Ganache. Is there any way to fix that issue or tranfer the ether using any other method? – Zeeshan Ahmad Khalil Sep 16 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.