I want to call a method of a contract from another contract. I've already read this post: calling one contract to another contract method, but it doesn't work for me.
When I create the caller and try to execute the Set() method it perfectly works, but if call the Get() it alwayas returns '0'.
Can someone help me?
These are my simple code:
pragma solidity ^0.4.0;
contract callee{
uint public x;
constructor() public
{
x = 1;
}
function set (uint k) public
{
x = k;
}
function get () public view returns (uint)
{
return x;
}
}
contract caller{
callee c;
constructor() public
{
c = new callee();
}
function get() public view returns (uint k)
{
return c.get();
}
function set(uint k) public
{
c.set(k);
}
function get_calle() public view returns (callee)
{
return c;
}
}
I'm using Web3 Provider and Remix to test.
I have tried to call get() from the callee after getting its location, and it returns the right value, so the set() methods works. Why can't I use get() from the caller?
Thank you!