Calling functions from other contracts solidity

0 votes

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.

Untitled:27:3: Error: Member "change" not found or not visible after argument-dependent lookup in address
    maker.change.value(5)(y);
    ^----------^

This is the code I am using: 

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);
}
}
Sep 17, 2018 in Blockchain by slayer
• 29,240 points
214 views

1 answer to this question.

0 votes

This code worked for me:

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);
 }
 }
answered Sep 17, 2018 by digger
• 26,600 points

Related Questions In Blockchain

+1 vote
0 answers

Can I change the network id in ganache GUI? Is it work for calling the functions in solidity?

Can I change the network id in ...READ MORE

Aug 16 in Blockchain by anonymous

edited Aug 19 by Omkar 87 views
0 votes
1 answer
0 votes
1 answer

How to create tokens in smart contracts from node.js?

Any modification to the Ethereum Blockchain will ...READ MORE

answered Jun 26, 2018 in Blockchain by Shashank
• 10,350 points
184 views
0 votes
1 answer

How Hyperledger projects are different from each other?

Hyperledger includes a range of business Blockchain ...READ MORE

answered Jul 11, 2018 in Blockchain by shweta
• 440 points
40 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,810 points
186 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,600 points
5,243 views
0 votes
1 answer
0 votes
1 answer

How to access bitcoin Daemon from other services?

You don't need all these things to ...READ MORE

answered Aug 29, 2018 in Blockchain by digger
• 26,600 points
285 views
+1 vote
1 answer

Calling deployed smart contract from node.js

contractInstance.wakeUp.call is calling the function as constant, but ...READ MORE

answered Sep 26, 2018 in Blockchain by digger
• 26,600 points
1,079 views