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 | |
// using the latest version | |
pragma solidity >=0.7.0 < 0.9.0; | |
import "hardhat/console.sol"; | |
// vulnerable Bank | |
contract Bank { | |
/*Contract that stores user balances. This is the vulnerable contract. This contract contains | |
the basic actions necessary to interact with its users, such as: get balance, add to balance, | |
and withdraw balance */ |
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 line tells us that the source code is licensed under the GPL version 3.0. | |
// SPDX-License-Identifier: GPL-3.0 | |
// This line specifies that the source code is written for Solidity compiler version 0.7.0 | |
// or a newer version of the language up to, but not including version 0.9.0. | |
pragma solidity >=0.7.0 <0.9.0; | |
// A contract is declared using a contract keyword followed by the contract's name | |
contract Storage { |
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
pragma solidity ^0.8.0; | |
interface IERC20 { | |
function totalSupply() external view returns (uint256); | |
function balanceOf(address account) external view returns (uint256); | |
} | |
contract Token { | |
// state variable called ERC20ContractAddress that represents the address of the ERC20 contract |
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
contract Owner { | |
address owner; | |
function setOwner() public { | |
owner = msg.sender; | |
} | |
} | |
contract Suicide is Owner { | |
function destroy() public { | |
if (msg.sender == owner) selfdestruct(payable(owner)); |
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
contract A {} | |
contract B {} | |
contract C is A, B {} | |
// Setting Constructor in base contract | |
contract A { | |
uint a; |
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: Unlicensed | |
pragma solidity ^0.8.0; | |
abstract contract HelloWorld { | |
string public message; | |
constructor(string memory _message){ | |
message = _message; | |
} |
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
pragma solidity ^0.8.0; | |
contract DepositEther { | |
event Deposit( | |
address indexed _from, | |
uint indexed _id, | |
uint _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
library arithmetic { | |
function multiply(uint _a, uint _b) returns (uint) { | |
return _a * _b; | |
} | |
} | |
contract C { | |
uint timesUp; |
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
library arithmetic { | |
function add(uint _a, uint _b) returns (uint) { | |
return _a + _b; | |
} | |
} | |
contract C { | |
using arithmetic 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
pragma solidity ^0.8.0; | |
contract Donation { | |
// input your default donor address | |
address public donor = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4; | |
uint constant DONATION_FEE = 2 ether; | |
modifier onlyDonor() { | |
require(msg.sender == donor,"Only buyer can call this."); |
OlderNewer