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.

  • Your question title doesn't match the actual compiler output you shared. – user19510 Jun 16 at 6:19
  • Thanks. I have corrected the question to reflect my changes after the title error. – zak100 Jun 16 at 13:23
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!

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 {}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.