Skip to content

Instantly share code, notes, and snippets.

@iphelix
Last active November 13, 2020 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iphelix/20afcf7a67d9bf6ac2cd287ab5c44080 to your computer and use it in GitHub Desktop.
Save iphelix/20afcf7a67d9bf6ac2cd287ab5c44080 to your computer and use it in GitHub Desktop.
Damn Vulnerable DeFi - Unstoppable
IERC20 public damnValuableToken;
uint256 public poolBalance;
constructor(address tokenAddress) public {
require(tokenAddress != address(0), "Token address cannot be zero");
damnValuableToken = IERC20(tokenAddress);
}
function depositTokens(uint256 amount) external nonReentrant {
require(amount > 0, "Must deposit at least one token");
// Transfer token from sender. Sender must have first approved them.
damnValuableToken.transferFrom(msg.sender, address(this), amount);
poolBalance = poolBalance.add(amount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment