Skip to content

Instantly share code, notes, and snippets.

@devtooligan
devtooligan / UnrolledLoopTest.sol
Last active July 28, 2023 20:42
unrolled loop
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "forge-std/Test.sol";
contract UnrolledLoopTest is Test {
function _transfer1(uint256 counter) internal returns (uint256) {
// token.transfer(addressList[counter], amount);
return counter + 1;
}
@devtooligan
devtooligan / TestIsPayable.sol
Created July 1, 2023 19:54
Utility to check if a function is payable
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "forge-std/Test.sol";
contract Utility {
error BadCalldata();
error NonPayable();
error Payable();
error NoCode();
@devtooligan
devtooligan / cursedbeaconproxy.sol
Last active April 9, 2024 16:10
PoC of crit bug found in Astaria.xyz's custom BeaconProxy contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
contract SheHateMe {
receive() external payable {}
function getImpl(uint8 x) public returns (address) {
return address(this);
@devtooligan
devtooligan / emitRevertTest.sol
Last active June 15, 2023 22:36
Foundry test - Emit event and revert
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "forge-std/Test.sol";
contract Reverter {
event Test();
function emitAndRevert() external {
emit Test();
@devtooligan
devtooligan / pureConsole.sol
Last active January 21, 2024 14:25
console.log from pure functions h/t @z0age
// @author original POC by @z0age
library pureConsole {
/*********************
* string + uint256
********************/
function log(string memory errorMessage, uint256 value) internal pure {
#!/bin/bash
alias c='code .'
alias cdh='cd $HOME'
alias ls='ls -la'
alias sl="ls"
alias cls='clear'
alias g='git status'
alias gap='git add -p'
alias gl='git log'
@devtooligan
devtooligan / UniV3LPWrapper.sol
Last active December 26, 2023 22:43
There are 2 critical vulnerabilities in here. Can you find them?
/// @notice These functions are part of a contract that
/// wraps a user's Uniswap V3 liquidity positions in an ERC20 token, `wrappedToken`.
// *** wrappedToken is a standard ERC20 token. ***
uint256 public protocolFee = 5;
function deposit(
IUniswapV3Pool pool,
int24 tickLower,
int24 tickUpper,
@devtooligan
devtooligan / OptimizedMint150.sol
Created November 2, 2022 19:36
RareSkills challenge
//SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.15;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "hardhat/console.sol";
// You may not modify this contract
contract NotRareToken is ERC721 {
mapping(address => bool) private alreadyMinted;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "forge-std/Test.sol";
contract TestDeleteMappingInStruct is Test {
/// @param enabled Whether the token is enabled or not
/// @param balances Mapping of user address to balance
struct Token {
bool enabled;
@devtooligan
devtooligan / TestDeleteStructWDynamicArray.sol
Created October 11, 2022 17:44
Test if Solidity properly handles `delete` with a dynamic array inside a struct (inside a mapping)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "forge-std/Test.sol";
contract Test67 is Test {
struct S2 {
uint256 a2;
uint256 b2;
}