Skip to content

Instantly share code, notes, and snippets.

@MCarlomagno
Last active March 21, 2022 00:30
Show Gist options
  • Save MCarlomagno/22a5eded98fd637011c38700e686328d to your computer and use it in GitHub Desktop.
Save MCarlomagno/22a5eded98fd637011c38700e686328d to your computer and use it in GitHub Desktop.
pragma solidity >=0.7.0 <0.9.0;
contract Chat {
// ...
// We can use an autoincremental id for each new message.
uint lastMessageId;
function sendMessage(string _text) public {
// increments id and sends message.
lastMessageId++;
sendMessageEvent(lastMessageId, msg.sender, _text);
}
}
@MCarlomagno
Copy link
Author

Hi Nicolas! Yes, you are totally right, I refactored the variable name and I forgot to replace it in that line. Anyway, the full function code seems to be right. Thanks a lot for the correction :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment