Skip to content

Instantly share code, notes, and snippets.

@PraneshASP
PraneshASP / Test.t.sol
Last active February 13, 2024 05:11
Using Mesc in foundry tests to avoid hardcoding urls.
// See Mesc Reference for setup: https://github.com/paradigmxyz/mesc/tree/main/cli#reference
contract TestSetup is Test {
function fetchRpcUrlFromMesc(string memory networkName) internal returns (string memory url) {
string[] memory inputs = new string[](3);
inputs[0] = "mesc";
inputs[1] = "url";
inputs[2] = networkName;
@Shungy
Shungy / EIP138128.md
Last active December 26, 2023 22:21
EIP138128: Custom selector and encodings (Very early draft)

Using LEB128 encoding scheme for custom abi/interface.

ERC-138128: Custom function selector and calldata encoding scheme declaration standard

  • A contract SHOULD use ERC-165 standard to declare its support for ERC-138128 standard.
  • A contract supporting ERC-138128 MUST have these two view functions: customSelectors() and customEncodings().

customSelectors()

This function is used to declare alternative function selectors for any number of standard function signatures. This function MUST have the following interface.

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;
import "hardhat/console.sol";
contract TryCatchCaller {
TryCatchCallee calee;
constructor () {
calee = new TryCatchCallee();
@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();
@MerlinEgalite
MerlinEgalite / CreateSelfdestruct.sol
Last active May 26, 2023 06:24
Tornado Cash Governance Hack
pragma solidity >=0.8.0;
import "forge-std/Test.sol";
import "forge-std/console2.sol";
contract ContractA {
function destroy() public {
selfdestruct(payable(0));
}
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;
import { Script } from "forge-std/Script.sol";
abstract contract BaseScript is Script {
/// @dev Included to enable compilation of the script without a $MNEMONIC environment variable.
string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk";
/// @dev Needed for the deterministic deployments.
echo ""
echo "************ Github Dork Links (must be logged in) *******************"
echo ""
echo " password"
echo "https://github.com/search?q="hackertarget.site"+password&type=Code"
echo "https://github.com/search?q=""hackertarget""+password&type=Code"
echo ""
echo " npmrc _auth"
@brockelmore
brockelmore / bedrock_deploy.sol
Last active April 19, 2024 22:28
Optimism-Bedrock deployment with foundry
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.15;
import "forge-std/Script.sol";
// L1
import { L1CrossDomainMessenger } from "../L1/L1CrossDomainMessenger.sol";
import { L1ERC721Bridge } from "../L1/L1ERC721Bridge.sol";
import { L1StandardBridge } from "../L1/L1StandardBridge.sol";
import { L2OutputOracle } from "../L1/L2OutputOracle.sol";
@Zer0dot
Zer0dot / ImmutableStrings.sol
Last active January 17, 2023 22:22
A library with a custom type to introduce immutable strings of length less than 32 bytes.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
/**
* @title ImmutableStringLib
* @author Zer0dot
*
* @notice This library introduces an abstraction to store and decode immutable strings.
* This is necessary because simply casting a string to a bytes32 variable will lose the
* length, which will be hardcoded as 32 upon re-converting via abi.encode.