0

I state that I'm a solidity rookie. Btw the compiler give me error "24:46:ParserError: expected ',' but got identifier receive().." and I can't understand where I should put the ",". Thanks for your help.enter image description here

pragma solidity ^0.6.0;

contract ReavealMeASecret{
  address payable public whoNeed;
  string secret= "blabla";
  bool payment;

  event Reveal(uint _amount);

  constructor () public {
      whoNeed = msg.sender;
      payment = false;
  }

  modifier OnlyIfWhoNeed (address _whoNeed){
      require (msg.sender == _whoNeed, "Non ti è dato saperlo");
      _;
  }
  modifier Amount(uint _amount){
      require (msg.value >= _amount, "Se il segreto vuoi sapere, il soldo giusto devi avere");
      _;
  }

  receive() external payable OnlyIfWhoNeed Amount(2 Ether){
      owner.transfer (msg.value);
      payment = true;
      emit Reveal(msg.value);
  }

}

enter image description here

1 Answer 1

2

The error is cause because Ether is not a keyword. You need to lowercase it, so it should be changed to 2 ether, else Solidity does not recognise it as a keyword and tries to apply a different parsing flow.

See https://docs.soliditylang.org/en/v0.8.10/units-and-global-variables.html#ether-units

I see 2 more errors in your code:

  1. OnlyIfWhoNeed takes a parameter which is not provided
  2. owner is not defined

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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