solidity – Resolving ‘Keyword Memory in Event Definition’ Compilation Error

solidity

Here is an event defined in a contract. However it throws an error when compiling:

pragma "^0.7.0";

    event _tradeComplete(address _poster, string memory  _posterItemName, uint256 _posterItemID, address _bidder,  string memory _bidderItemName, uint256 _bidderItemID, uint256 _value);  //keyword memory throws error

However the error disappears if memory is removed. Why memory can't be used here?

enter image description here

Best Answer

You don't have to add data location for variables when declaring a event. Remove the memory keyword from your events, this should work:

event _tradeComplete(address _poster, string _posterItemName, uint256 _posterItemID, address _bidder, string _bidderItemName, uint256 _bidderItemID, uint256 _value);