0

I am trying to execute the following code:

pragma solidity ^0.5.1;

contract contractA {
    function blah(int x, int y) public payable {}
}
contract contractB {
   function invokeContractA() { 
      address a = contractA.address(this);
      uint ValueToSend = 1234;  
      a.blah.value(ValueToSend)(2, 3);
   }  
}

I was getting following error in the ocde:

browser/callMethod.sol:7:31: ParserError: Expected identifier but got 'address' address a = contractA.address(this); ^-----^

After searching from ethereum.stackexchange, I found the solution and now my contract B looks like this:

    contract contractB {
    function invokeContractA(address _addA) public  { 
        contractA a = contractA(_addA);
        uint ValueToSend = 1234;    
        a.blah.value(ValueToSend)(2, 3);
    }  
}

Now I am getting following error on remix ide:

browser/callMethod.sol:4:19: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning. function blah(int x, int y) public payable {} ^---^

Some body please guide me.

Zulfi.

zak100
  • 1,406
  • 1
  • 13
  • 37

2 Answers2

1

The "error" you're seeing is not an error. It's a warning.

As the warning says, the cause is unused parameters. You can ignore the warning if you want, or you can address it by removing the unused parameters or just their names:

// Either this:
function blah() public payable {}

// Or this:
function blah(int, int) public payable {}
user19510
  • 27,999
  • 2
  • 30
  • 48
1

Your function blah is not doing anything (it's useless basically), that's what the error is.

What you can do is, you can return something from that blah function like this:

pragma solidity ^0.5.1;

contract contractA {
    function blah(int x, int y) public payable returns (int) {
        return x+y;
    }
}

Good luck!

itsHarshad
  • 491
  • 3
  • 8