Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save z0r0z/9bf78973ac432651cbdc3ece4f9c3fb3 to your computer and use it in GitHub Desktop.
gist
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "https://github.com/lexDAO/Kali/blob/main/contracts/tokens/erc20/ERC20.sol";
interface IERC20 {
function balance(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external;
}
contract Payment is ERC20 {
address public owner = msg.sender;
string public agreement;
uint256 public price = 0.1 ether;
uint256 public payment = 0.1 ether;
uint256 public userPayment = 0.01 ether;
IERC20 public paymentToken = IERC20(0x8ad3aA5d5ff084307d28C8f514D7a193B2Bfe725);
mapping(address => bool) whitelisted;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
modifier onlyWhitelisted {
require(whitelisted[msg.sender]);
_;
}
constructor() ERC20("rossCO", "RC", 18) {}
function whitelist(address[] calldata users) public onlyOwner {
unchecked {
for (uint256 i; i < users.length; i++) {
whitelisted[users[i]] = true;
}
}
}
function setAgreement(string calldata agreement_) public onlyOwner {
agreement = agreement_;
}
function takePayUser() public onlyWhitelisted {
paymentToken.transfer(msg.sender, 10 ether);
}
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 onlyOwner {
(bool success, ) = msg.sender.call{value: payment}("");
require(success);
}
/// @notice User by calling this function agrees to the terms set in `agreement`
receive() external payable {
require(msg.value == price);
_mint(msg.sender, 100 ether);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment