Created
January 14, 2022 17:24
-
-
Save z0r0z/f976d4ff712ea1d2f7c67320e0bce209 to your computer and use it in GitHub Desktop.
simple push / pull payment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.10; | |
| contract Payment { | |
| address public payee = msg.sender; | |
| string public agreement; | |
| uint256 public payment = 0.1 ether; | |
| modifier onlyPayee { | |
| require(msg.sender == payee); | |
| _; | |
| } | |
| function setAgreement(string calldata agreement_) public { | |
| agreement = agreement_; | |
| } | |
| function payGroup(address[] calldata users) public payable { | |
| unchecked { | |
| for (uint256 i; i < users.length; i++) { | |
| (bool success, ) = users[i].call{value: msg.value / users.length}(""); | |
| require(success); | |
| } | |
| } | |
| } | |
| function takePay() public onlyPayee { | |
| (bool success, ) = msg.sender.call{value: payment}(""); | |
| require(success); | |
| } | |
| receive() external payable {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment