-1

I'm using pragma solidity >=0.4.0 <0.9.0;

Line 34 with below code:

event studentAdded(string memory full_name, uint256 memory st_id);

I'm facing this error. Can anyone help?

ParserError: Expected ',' but got 'memory' --> contracts/Scorecard.sol:34:31: | 34 | event studentAdded(string memory full_name, uint256 memory st_id); | ^^^^^^

While removing the memory keyword from all arguments of event definitions. I was able to compile successfully but I still can't understand the reasoning behind this. The data location should be either memory or storage for all the variables right?

  • I think the default data-location it uses for arguments defined in the events is `storage` because when we emit the event, the data will be included in the transaction logs which means it will be stored on the blockchain. While when we're using the `memory` data-location for a variable, the data doesn't reside on the blockchain. Can anyone tell me if this is the correct reasoning or am I missing something here? – Chandu Vamsi Oct 28 '22 at 10:21

2 Answers2

3

memory key word should be added only for string or array variables. Not required for uint variables. Try removing memory for uint256 variable.

Dushyanth Kumar Reddy
  • 1,222
  • 11
  • 21
0

when declaring any uint type for example:uint256 type you don't need to use memory / calldata as a visibility as they work mostly for strings not numbers.