julien/lovepublic Fork 0
9bf25a7597df88a258ef7ee1fa6b97a8b2d8ec8b
Commits
Clone
git clone https://git.rickub.com/julien/love.git
git clone ssh://git@rickub.com/julien/love.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Love.sol · 25 lines · 777 BSolidity Blame HistoryRaw
add love contract 9bf25a7 julienbrg 10h ago1// SPDX-License-Identifier: MIT
2pragma solidity ^0.8.30;
3
4/// @title Love
5/// @notice A minimal on-chain counter of love sent between addresses.
6contract 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}