Skip to content

Instantly share code, notes, and snippets.

View salmanbao's full-sized avatar
🏢
Working from office

Muhammad Salman salmanbao

🏢
Working from office
View GitHub Profile
@salmanbao
salmanbao / SPHINCS-PLUS.md
Created March 8, 2025 15:51
SPHINCS+ Basci Details

SPHINCS+ Flow: Components, Responsibilities, and Sequence


1. Components and Responsibilities

Component Responsibility
Seed (SK.seed) Generates all private keys via a pseudorandom function (PRF).
FORS Signs the message digest using a few-time signature scheme (bottom layer).
WOTS+ Signs the FORS root and hypertree layer roots (one-time signatures).
@salmanbao
salmanbao / modifyState.ts
Last active April 7, 2023 09:27
Modify Mainnet Fork contract state
import { BigNumber} from "ethers";
import { ethers } from "hardhat";
import { mine,setStorageAt } from "@nomicfoundation/hardhat-network-helpers";
/*
* @param account is account of the user
* @param token is token address
* @param balance is the balance you want set for the give account
* @param slot is slot number on which the required state variable exist(i.e: mapping of _balances)
slither . --print human-summary
slither . --print contract-summary
slither . --print function-summary
slither . --print vars-and-auth
slither . --print call-graph
slither . --print inheritance-graph
slither . --print cfg
@salmanbao
salmanbao / uniswap-v3-example.sol
Created October 6, 2022 14:12 — forked from mempirate/uniswap-v3-example.sol
Simple example on how to swap on UniswapV3 with the SwapRouter
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
pragma abicoder v2;
import "@uniswap/v2-periphery/contracts/interfaces/IWETH.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
@salmanbao
salmanbao / ETH address
Created July 20, 2022 11:42
eth address on Ethereum
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
@salmanbao
salmanbao / encoding.sol
Created June 30, 2022 06:48
Solidity Encoding
pragma solidity ^0.8.0;
import "hardhat/console.sol";
/*
1. abi.encode(...) returns (bytes) :
ABI encodes the given arguments. Arguments can be of any type. It returns the encoded data as bytes .
2. abi.encodePacked(...) returns (bytes) :
This performs packed encoding of the given arguments. Arguments can be of any type. It returns the packed encoding of the data as bytes .
3. abi.encodeWithSelector(bytes4 selector, ...) returns (bytes) :
ABI encodes the given arguments. The first argument takes a function selector and from the second onward it takes any data type. It returns the encoded data as bytes .
import { network, ethers } from "hardhat";
const { ethers } = require("hardhat");
await network.provider.request({
method: "hardhat_impersonateAccount",
params: ["0x..........................."],
});
if you use hardhat-ethers
curl -s https://api.github.com/users/decentraland/repos?page=1&per_page=100 | jq -r ".[].ssh_url" | xargs -L1 git clone
@salmanbao
salmanbao / hardhat evm hacks
Created August 6, 2021 05:19
Hardhat network methods
import { ethers } from "hardhat";
ethers.provider.send("evm_increaseTime", [duration]);
ethers.provider.send("evm_mine", []);
await ethers.provider.send("evm_setNextBlockTimestamp", [1625097600])
await ethers.provider.send("evm_mine")
await ethers.provider.send("hardhat_dropTransaction", [txHash]);
pragma solidity 0.8.0;
contract Average {
function avg(uint256 x, uint256 y) external view returns (uint256 result) {
unchecked {
result = (x >> 1) + (y >> 1) + (x & y & 1);
}
}