Created
November 21, 2021 10:04
-
-
Save rgsk/8089d4a58e72c5fa5d0d3c1f5d512d5b to your computer and use it in GitHub Desktop.
web 3.0 Session 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.7.0 <0.9.0; | |
contract Kudos { | |
mapping (address => Kudo[]) allKudos; | |
function giveKudos(address who, string memory what, string memory comments) public { | |
Kudo memory kudo = Kudo(what, msg.sender, comments); | |
allKudos[who].push(kudo); | |
} | |
function getKudosAtIndex(address who, uint index) public view returns (string memory, address, string memory) { | |
Kudo memory kudo = allKudos[who][index]; | |
return (kudo.what, kudo.giver, kudo.comments); | |
} | |
function getKudosLength(address who) public view returns (uint) { | |
Kudo[] memory kudos = allKudos[who]; | |
return kudos.length; | |
} | |
} | |
struct Kudo { | |
string what; | |
address giver; | |
string comments; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment