1

I'm running into issues calling the function y() in the contract pullother. The input for the function y() is the output of the function g(). When I call y() using this input the output is blank ('' to be specific) rather than 15. I'm not exactly sure what I'm doing wrong here as this seems to align with the examples I see online of people successfully calling functions from other contracts.

The below is Untitled.sol

    pragma solidity ^0.4.6;

    contract helloworld {

    function f() returns (uint){
    return 15;
    }

    }

The below is the contract i would like to use to call the function f() in the contract helloworld.

pragma solidity ^0.4.6;

import "./Untitled.sol";

contract pullother {
address public hello;

function g() returns (address){
    hello = new helloworld();
    return hello;
}

function y(address contractadd) returns (uint){
    helloworld h = helloworld(contractadd);
    h.f();
}
}
2

I've tried your code in the solidity browser and it works

enter image description here

I think your need to use

return h.f()
  • I was able to call the function f() directly. I am unable to call the function f() by calling the function y() where the input is the output of function g(). Were you able to do this? – jbreezy May 2 '17 at 22:36
  • yest check the edit – Badr Bellaj May 2 '17 at 22:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.