Skip to main content
4 of 4
added 298 characters in body
Jaime
  • 8.4k
  • 1
  • 12
  • 20

How do i get to return value form one smart contract function into another smart contract on private ethereum network?

Here it is my called function.

pragma solidity ^0.4.19;

contract Called{

    string public name;

    function set(string _var) {
        name = _var;
    }

    function   get() view returns (string){
        return name;
    }
    
    
    function A () payable {

    }
    
    
    
}

Here it is my Caller function.

pragma solidity ^0.4.19;

interface Called{

    function set(string);

    function get() view returns (string);
}

contract Caller {
    
    string public new_name;
    
    Called public called_address;

    function set_address(address _addy) {
        called_address = Called(_addy);
    }

    function caller_set(string _var) {
      
        called_address.set(_var);
    } 
    function caller_get() {
        new_name= called_address.get();
        
    }

    
    function B () payable {

    }
    
 
}

Here is my genesis file

{
  "config": {
        "chainId": 8888,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0xffffffffffffffff",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

I am here interacting with called contract using caller contract. It works fine with in remix browser(without connected to ethereum network). When i connect remix browser to my private ethereum network caller_set function of caller contract works fine but when i called caller_get function it gives the error "gas required exceeds allowance or always failing transaction". I have given more and more gas but it always failed. somebody please help.