Skip to content

Instantly share code, notes, and snippets.

@z0r0z
Created January 14, 2022 17:24
Show Gist options
  • Select an option

  • Save z0r0z/f976d4ff712ea1d2f7c67320e0bce209 to your computer and use it in GitHub Desktop.

Select an option

Save z0r0z/f976d4ff712ea1d2f7c67320e0bce209 to your computer and use it in GitHub Desktop.
simple push / pull payment
// 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