How would I set a limit to the amount of people who could send ether to a contract? I can't find anything on google or youtube. Ideally the contract would stop taking inputs after 2(or however many) different people have sent an amount.
Below is simple code from https://solidity-by-example.org/sending-ether/ for sending ether to an address, but i'm not sure what I would do. I'm using remix and running it with ganache on my machine. Is it possible to make it read-only after X transactions?
https://github.com/CrazybutSolid/ethereum-lottery/blob/master/contracts/lottery.sol has a kind of similar example but it seems too complicated and I'm still a noob.
pragma solidity ^0.5.16;
contract Receive {
function () external payable {}
function getBalance() public view returns (uint) {
return address(this).balance;
}
}
contract Send {
function sendViaCall(address payable _to) public payable {
(bool sent, bytes memory data) = _to.call.value(msg.value)("");
require(sent, "Failed to send Ether");
}
}
Thank you