Created
July 21, 2018 19:53
-
-
Save vasa-develop/6bc70e63ae1d4eaf8587599bca383387 to your computer and use it in GitHub Desktop.
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
This file contains 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
contract DistributeTokens { | |
address public owner; // gets set somewhere | |
address[] investors; // array of investors | |
uint[] investorTokens; // the amount of tokens each investor gets | |
// ... extra functionality, including transfertoken() | |
function invest() public payable { | |
investors.push(msg.sender); | |
investorTokens.push(msg.value * 5); // 5 times the wei sent | |
} | |
function distribute() public { | |
require(msg.sender == owner); // only owner | |
for(uint i = 0; i < investors.length; i++) { | |
// here transferToken(to,amount) transfers "amount" of tokens to the address "to" | |
transferToken(investors[i],investorTokens[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment