Skip to content

Instantly share code, notes, and snippets.

Changes included in this gist

Hand-written (actual logic changes)

  • libp2p/pubsub/pubsub.py
  • libp2p/pubsub/gossipsub.py
  • libp2p/tools/constants.py

Protobuf schema changes

  • libp2p/pubsub/pb/rpc.proto
  • libp2p/kad_dht/pb/kademlia.proto
@pope-h
pope-h / ComplianceDatabase.sol
Last active April 23, 2024 03:39
No-Loss Prize Savings Product with DAO Governance
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/access/Ownable.sol";
contract ComplianceDatabase is Ownable {
mapping(string => string) public userRegulations;
mapping(string => string) public daoRegulations;
constructor() Ownable(msg.sender) {
@pope-h
pope-h / SideEntrance.sol
Created April 6, 2024 19:44
A contract to exploit a flashloan vunerability
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import {Utilities} from "../../utils/Utilities.sol";
import "forge-std/Test.sol";
import {SideEntranceLenderPool} from "../src/SideEntranceLenderPool.sol";
contract SideEntrance is Test {
uint256 internal constant ETHER_IN_POOL = 1_000e18;
@pope-h
pope-h / ExVIPBank.sol
Last active April 3, 2024 16:14
Exploit VIPBank
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "./VIP_Bank.sol";
contract Attacker {
VIP_Bank public bank;
constructor(VIP_Bank _bank) {
bank = _bank;
@pope-h
pope-h / FixVIPBank.sol
Last active April 3, 2024 16:28
Fixing VIPBank
// Add a state variable to act as a reentrancy guard
bool private locked = false;
function withdraw(uint _amount) public onlyVIP {
require(!locked, "Reentrant call detected!");
locked = true;
require(balances[msg.sender] >= _amount, "Not enough ether");
require(_amount <= maxETH, "Cannot withdraw more than 0.5 ETH per transaction");
@pope-h
pope-h / IPopeSaving.sol
Last active February 24, 2024 23:16
A simple contract to deposit funds
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IPopeSaving {
function deposit() external payable;
function getBalance(address _addr) external view returns (uint256);
}
@pope-h
pope-h / AbstractInterface.sol
Created February 11, 2024 02:53
A smart contract that implements both an abstract contract and an interface
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
abstract contract AbsMaths {
function add(uint x, uint y) external pure virtual returns (uint);
function sub(uint x, uint y) external pure virtual returns (uint) {
require(x > y, "x must be greater than y");
return x - y;
}
}
@pope-h
pope-h / Fallback.sol
Created February 10, 2024 18:47
A Smart contract that accepts ether and handles any unrecognized calls.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
contract Fallback {
address owner;
constructor() {
owner = msg.sender;
}
@pope-h
pope-h / MetamaskConnect.js
Created February 8, 2024 01:07
A script to connect Metamask wallet
import React, {useState} from 'react'
import {ethers} from 'ethers'
import './WalletCard.css'
const WalletCard = () => {
const [errorMessage, setErrorMessage] = useState(null);
const [defaultAccount, setDefaultAccount] = useState(null);
const [userBalance, setUserBalance] = useState(null);
const [connButtonText, setConnButtonText] = useState('Connect Wallet');
@pope-h
pope-h / Proxy.sol
Created February 8, 2024 00:41
A smart contract that is upgradeable using a proxy contract
// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
contract Original {
address public owner;
uint public num;
uint public value;
function setNum(uint _num) public payable {
num = _num;