Reputation: 11
I am trying to create a new instance of the Taker contract from the Maker contract and send some value to it.
Then later I would like to send a value back to the Maker contract from the Taker contract
maker.change.value(5)(y);
However it cannot find the function called "change" and throws the error. The only possible explanation I can think of is that they need to be executed asynchronously but are compiled at the same time.
Untitled:27:3: Error: Member "change" not found or not visible after argument-dependent lookup in address
maker.change.value(5)(y);
^----------^
(This is tested in Browser Solidity, Ethereum Studio and Truffle - all with the same error message)
Below is the full code.
I would be very grateful for any advice on how to solve this (and or references).
Thank you!
pragma solidity ^0.4.2;
contract Maker {
uint x;
function Maker() {
x = 5;
Taker take = new Taker(this, 2);
bool a = take.call.gas(200000).value(10)();
}
function change(uint val) external payable {
x = val;
}
}
contract Taker {
uint y;
address maker;
function Taker(address makerAddr, uint val) {
y = val;
maker = makerAddr;
}
function sendChange() {
maker.change.value(5)(y);
}
}
Upvotes: 1
Views: 1556
Reputation: 56
This code worked with me in Browser Solidity
pragma solidity ^0.4.2;
contract Maker {
uint x;
function Maker() {
x = 5;
Taker take = new Taker(this, 2);
bool a = take.call.gas(200000).value(10)();
}
function change(uint val) external {
x = val;
}
}
contract Taker {
uint y;
Maker maker;
function Taker(address makerAddr, uint val) {
y = val;
maker = Maker(makerAddr);
}
function sendChange() {
maker.change(5);
}
}
Upvotes: 1