# Donation
A candidate you don’t like is accepting campaign contributions via the smart contract below.
To complete this challenge, steal the candidate’s ether.
pragma solidity ^0.4.21;
contract Donation {
struct DonationInfo {
uint256 timestamp;
uint256 etherAmount;
}
DonationInfo[] public donations;
address public owner;
function Donation() public payable {
require(msg.value == 1000000000);
owner = msg.sender;
}
function isComplete() public view returns (bool) {
return address(this).balance == 0;
}
function donate(uint256 etherAmount) public payable {
// amount is in ether, but msg.value is in wei
uint256 scale = 10**18 * 1 ether;
require(msg.value == etherAmount / scale);
DonationInfo donation;
donation.timestamp = now;
donation.etherAmount = etherAmount;
donations.push(donation);
}
function withdraw() public {
require(msg.sender == owner);
msg.sender.transfer(address(this).balance);
}
}
← DeFi Fifty Years →