0

I am trying to compile the following contract on Remix.

    pragma solidity ^0.4.24;

contract financialContracts3{

address issuer;
constructor() public{
   issuer = msg.sender;
}
modifier ifIssuer(){
   if(issuer != msg.sender){
      revert();
   }else {
        _;//underscore
   }
}
function receiveFunds( )public payable{

}
function getValue() public constant {
   return issuer.balance;
}
}

I am getting following error message:

browser/financialContract3.sol:20:4: TypeError: Different number of arguments in return statement than in returns declaration. return issuer.balance;

^-------------------^

Some body please guide me.

Zulfi.

  • I am getting following warning now: browser/financialContract3.sol:20:11: Warning: Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member, for example use "address(contract).balance" instead. return this.balance; ^----------^ – zak100 Nov 22 '18 at 13:34
  • I tried the following and it worked: function getValue() public view returns(uint) { address myAddress = this; return myAddress.balance; } as provided a solution at another place. – zak100 Nov 22 '18 at 13:55
1

In Solidity, you must be explicit about the variables that you return from a function. So here would be a corrected version of your code:

function getValue() public view returns(uint){
   return this.balance;
}

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.