Skip to content

Instantly share code, notes, and snippets.

View AyDeveloper's full-sized avatar

AyDeveloper AyDeveloper

View GitHub Profile
// 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 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 {
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
contract Owner {
address owner;
function setOwner() public {
owner = msg.sender;
}
}
contract Suicide is Owner {
function destroy() public {
if (msg.sender == owner) selfdestruct(payable(owner));
contract A {}
contract B {}
contract C is A, B {}
// Setting Constructor in base contract
contract A {
uint a;
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.0;
abstract contract HelloWorld {
string public message;
constructor(string memory _message){
message = _message;
}
pragma solidity ^0.8.0;
contract DepositEther {
event Deposit(
address indexed _from,
uint indexed _id,
uint _value
);
library arithmetic {
function multiply(uint _a, uint _b) returns (uint) {
return _a * _b;
}
}
contract C {
uint timesUp;
library arithmetic {
function add(uint _a, uint _b) returns (uint) {
return _a + _b;
}
}
contract C {
using arithmetic for uint;
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.");