1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
/// @title Love
/// @notice A minimal on-chain counter of love sent between addresses.
contract Love {
mapping(address sender => mapping(address recipient => uint256 amount)) public sent;
mapping(address recipient => uint256 amount) public received;
event LoveSent(address indexed from, address indexed to, uint256 amount);
error SelfLove();
error ZeroAmount();
/// @notice Send `amount` units of love to `to`.
function send(address to, uint256 amount) external {
if (to == msg.sender) revert SelfLove();
if (amount == 0) revert ZeroAmount();
sent[msg.sender][to] += amount;
received[to] += amount;
emit LoveSent(msg.sender, to, amount);
}
}
|