Skip to content

Instantly share code, notes, and snippets.

@vasa-develop
Created July 21, 2018 19:53
Show Gist options
  • Save vasa-develop/6bc70e63ae1d4eaf8587599bca383387 to your computer and use it in GitHub Desktop.
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.
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