Skip to content

Instantly share code, notes, and snippets.

@depresto
depresto / SBT.sol
Last active October 14, 2022 06:25
SBT - Soulbound Token
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
/**
* An experiment in Soul Bound Tokens (SBT's) following Vitalik's
* co-authored whitepaper at:
* https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4105763
*
* I propose for a rename to Non-Transferable Tokens NTT's
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract AuthorizedVault is ReentrancyGuard {
using SafeMath for uint256;
uint256 public fee;
mapping(address => uint256) public balance;
@depresto
depresto / Attacker.sol
Created August 30, 2022 05:16
Denial of Service Attack
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./AuctionContract.sol";
contract Attacker {
AuctionContract auction;
constructor(address auctionAddress) {
auction = AuctionContract(auctionAddress);
@depresto
depresto / Attacker.sol
Created August 30, 2022 05:13
Re-Entrancy Attack
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
interface Vault {
function deposit() external payable;
function withdraw(uint256 amount) external;
function withdrawAll() external payable;
pragma solidity 0.8.7;
contract Vault {
mapping(address => uint256) public accountBalance;
function withdraw(uint256 amount) public {
uint256 currentBalance = accountBalance[msg.sender];
require(amount <= currentBalance, "Account balance is not enough");
accountBalance[msg.sender] -= amount;
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.7;
contract Multisig {
uint256 minSignatures = 3;
address private contractOwner;
mapping(address => bool) private owners;
struct Transaction {
address to;
uint256 amount;
@depresto
depresto / contract.js
Last active June 15, 2022 12:08
Uniswap V1 interaction for https://playground.ethers.org/
const uniSwapV1FactoryAddress = "0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95";
const usdcAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const factoryABI = [
{
name: "NewExchange",
inputs: [
{ type: "address", name: "token", indexed: true },
{ type: "address", name: "exchange", indexed: true },
],
anonymous: false,