Beginner
Deploying a Contract on Testnet — Kudos board build (step 3/6)
End-to-end deploy experience.
Developer Beginner
7/7 — Deploying a Contract on Testnet — Kudos board build (step 3/6)
GoalTrack activity: total kudos, per-recipient counts, and an event log.
What to write
- Counters
uint256 public totalKudos;andmapping(address => uint256) public kudosCount;.mapping(address => uint256) public kudosCount; uint256 public totalKudos;Public counters auto-generate getters and give users visibility.
- Event
emit who sent, who received, and the message.event KudosSent(address indexed from, address indexed to, string message);Indexed params make filtering easy in explorers and backends.
- sendKudos
write storage, bump counters, emit event.function sendKudos(address to, string calldata message) external { _lastKudos[to] = message; kudosCount[to] += 1; totalKudos += 1; emit KudosSent(msg.sender, to, message); }One function does all state changes and logging—easy to test.
Why Events make the app observable off-chain; counters quantify activity.
Try it Deploy, call sendKudos(); watch the event and the counters change.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract KudosBoard {
mapping(address => string) private _lastKudos;
mapping(address => uint256) public kudosCount;
uint256 public totalKudos;
event KudosSent(address indexed from, address indexed to, string message);
function sendKudos(address to, string calldata message) external {
_lastKudos[to] = message;
kudosCount[to] += 1;
totalKudos += 1;
emit KudosSent(msg.sender, to, message);
}
function lastKudos(address user) external view returns (string memory) {
return _lastKudos[user];
}
}
NextWe’ll keep extending this in the following lesson; this version already deploys and runs.