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.

add love contract 9bf25a7 · on 9bf25a7597df88a258ef7ee1fa6b97a8b2d8ec8b · julienbrg · 8h ago
Love.sol · 25 lines · 777 BSolidity Blame HistoryRaw
 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);
    }
}