dimanche 15 septembre 2019

“Out of Gas” while transferring ethereum from account to contract

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.

Aucun commentaire:

Enregistrer un commentaire