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