Skip to main content
added 136 characters in body
Source Link
ZhouW
  • 1.4k
  • 2
  • 18
  • 36

I'm trying to call a function in one contract from another contract with the following simple example:

Untitled.sol:

pragma solidity ^0.4.16;

contract helloworld {
function returnint() returns (uint) {
return 15;
}
}

And the second contract:

pragma solidity ^0.4.16;

import "./Untitled.sol";

contract pullother {
        
function callFunctionInContractOne (address _address) returns (uint) {
    helloworld contractOne = helloworld(_address);
    contractOne.returnint();
}
}

When calling callFunctionInContractOne() in the second contract, the address of the deployed Untitled.sol is given as a parameter, then the returnint() function in the first contract is called (which should return 15). When I try this in the remix editor I get the following returned instead:

enter image description here

I am copying from calling simple function from another contract but getting a different result. I've also tried running a function on one contract from another on a private blockchain in a similar way but am unsuccessful.

Adding a return value I get the same thing:

enter image description here

I'm trying to call a function in one contract from another contract with the following simple example:

Untitled.sol:

pragma solidity ^0.4.16;

contract helloworld {
function returnint() returns (uint) {
return 15;
}
}

And the second contract:

pragma solidity ^0.4.16;

import "./Untitled.sol";

contract pullother {
        
function callFunctionInContractOne (address _address) returns (uint) {
    helloworld contractOne = helloworld(_address);
    contractOne.returnint();
}
}

When calling callFunctionInContractOne() in the second contract, the address of the deployed Untitled.sol is given as a parameter, then the returnint() function in the first contract is called (which should return 15). When I try this in the remix editor I get the following returned instead:

enter image description here

I am copying from calling simple function from another contract but getting a different result. I've also tried running a function on one contract from another on a private blockchain in a similar way but am unsuccessful.

I'm trying to call a function in one contract from another contract with the following simple example:

Untitled.sol:

pragma solidity ^0.4.16;

contract helloworld {
function returnint() returns (uint) {
return 15;
}
}

And the second contract:

pragma solidity ^0.4.16;

import "./Untitled.sol";

contract pullother {
        
function callFunctionInContractOne (address _address) returns (uint) {
    helloworld contractOne = helloworld(_address);
    contractOne.returnint();
}
}

When calling callFunctionInContractOne() in the second contract, the address of the deployed Untitled.sol is given as a parameter, then the returnint() function in the first contract is called (which should return 15). When I try this in the remix editor I get the following returned instead:

enter image description here

I am copying from calling simple function from another contract but getting a different result. I've also tried running a function on one contract from another on a private blockchain in a similar way but am unsuccessful.

Adding a return value I get the same thing:

enter image description here

Source Link
ZhouW
  • 1.4k
  • 2
  • 18
  • 36

can't call function in one contract from another contract

I'm trying to call a function in one contract from another contract with the following simple example:

Untitled.sol:

pragma solidity ^0.4.16;

contract helloworld {
function returnint() returns (uint) {
return 15;
}
}

And the second contract:

pragma solidity ^0.4.16;

import "./Untitled.sol";

contract pullother {
        
function callFunctionInContractOne (address _address) returns (uint) {
    helloworld contractOne = helloworld(_address);
    contractOne.returnint();
}
}

When calling callFunctionInContractOne() in the second contract, the address of the deployed Untitled.sol is given as a parameter, then the returnint() function in the first contract is called (which should return 15). When I try this in the remix editor I get the following returned instead:

enter image description here

I am copying from calling simple function from another contract but getting a different result. I've also tried running a function on one contract from another on a private blockchain in a similar way but am unsuccessful.