# TokenDistributor
The owner wishes to distribute tokens amongst their investors, and they are doing
so with the distribute()
function which loops through all the investors and sends them their money.
How can you make this distribute function inoperable and prevent everyone from claiming their funds?
Hint: Can you make distribute a gas-guzzler?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
contract TokenDistributor {
address public owner;
address[] investors; // array of investors
uint[] investorTokens; // the amount of tokens each investor gets
function invest() public payable {
investors.push(msg.sender);
investorTokens.push(msg.value);
}
function distribute() public {
require(msg.sender == owner);
for(uint i = 0; i < investors.length; i++) {
transferToken(i);
}
}
function transferToken(uint index) private {
address to = investors[index];
uint amount = investorTokens[index];
investorTokens[index] = 0;
}
constructor() {
owner = msg.sender;
}
receive() external payable {}
}