-1

I am trying one Lottery contract in that I am using one function which give me error.

 function pickAWinner() public restricted {
    require(this.balance >= 10 ether);
    uint index = random() % players.length;
    players[index].transfer(this.balance);
    players = new address[](0);
  }

Getting below error, Below error I am getting other contract also as "Member "balance" not found or not visible after argument-dependent lookup in contract" I think there is issue with 'balance' keyword. however I Unable to fixed it.

  Error:-TypeError: Member "balance" not found or not visible after           
  argument-dependent lookup in contract Lottery. Use 
  "address(this).balance" to access this address member.
    require(this.balance >= 10 ether);
            ^----------^

How can I fixed it?

  • 1
    The error message tells you "use address(this).balance to access this address member." Is there a reason you haven't tried following these instructions? @goodvibration's answer is basically a rephrasing of the error message. – Rosco Kalis Jan 27 at 10:08
  • sorry @RoscoKalis, I have more careful to error massage, Next time I will thanks for notify me. – Abhijeet Samanta Jan 27 at 10:19
  • Mooi worries, good luck developing – Rosco Kalis Jan 27 at 10:19
2

Change this.balance to address(this).balance.

  • BTW, thought you said you needed to get some sleep. – goodvibration Jan 27 at 10:00
  • yes@goodvibration, however when I am trying sleep I can't because of this error and incomplete work once I get understand this issues then I can sleep. – Abhijeet Samanta Jan 27 at 10:13
  • Again thanks@goodvibration for reply on this, because of this community I am learning now. solidity community really helpful and amazing, I hope I could also give to this community. – Abhijeet Samanta Jan 27 at 10:16

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.