Skip to content

Instantly share code, notes, and snippets.

View pcaversaccio's full-sized avatar
πŸ’―
Percent Commitment

sudo rm -rf --no-preserve-root / pcaversaccio

πŸ’―
Percent Commitment
View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
contract SelectorsAndSignatures {
address public s_someAddress;
uint256 public s_amount;
function getSelectorOne() public pure returns(bytes4 selector){
selector = bytes4(keccak256(bytes("transfer(address,uint256)")));
}
@bennlee
bennlee / wildcards-in-paths.md
Last active December 19, 2024 08:02
What does the double asterisk(**) mean in the path?

What does the double asterisk(**) mean in the path?

There's two meaning of wildcards in paths for file collections.

  • * is a simple, non-recursive wildcard representing zero or more characters which you can use for paths and file names.
  • ** is a recursive wildcard which can only be used with paths, not file names.

For examples,

  • /var/log/** will match all files in /var/log and all files in all child directories, recursively.
  • /var/log/**/*.log will match all files whose names end in .log in /var/log and all files in all child directories, recursively.
  • /home/*/.bashrc will match all .bashrc files in all user's home directories.
@pcaversaccio
pcaversaccio / GasTesting.sol
Last active March 20, 2023 19:44
A Solidity contract to estimate the used gas via the `gasleft()` syntax for dedicated function calls.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
contract GasTesting {
function testInlined(uint256 length) external view returns (uint256 gasUsed) {
uint256 total;
uint256 startGas = gasleft();
for (uint256 i; i < length; i = _uncheckedInc(i)) {
total += i;
@yorickdowne
yorickdowne / SepoliaWhale.md
Last active February 22, 2025 06:32
Get that sweet Sepolia ETH

Sepolia is now on PoS

As of 2022/7/6, Sepolia has switched to PoS. The window to do some mining has closed.

Testnets after merge (original, old content from here)

It's mid 2022, Ethereum is still PoW and motoring towards merge / PoS. Surviving testnets will be Sepolia - currently PoW - and Goerli. Ropsten will be merged and then deprecated, Rinkeby and Kovan won't be merged.

I want to "get ready" for some Sepolia testing pre- and post-merge. Sepolia will not have a public validator set; testing post-merge will be limited to running applications on it. As Sepolia is PoW, I can actually go mine myself some SepplETH. Here's how.

name: CI
on:
push:
branches:
- master
pull_request:
jobs:
run-ci:
runs-on: ubuntu-latest
@z0r0z
z0r0z / FlashPot.sol
Last active January 10, 2024 03:26
flash-lendable ETH wrapper with elastic shares
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity >=0.8.4;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*///////////////////////////////////////////////////////////////
@botdad
botdad / CREATE07Proxy.sol
Created December 22, 2021 19:14
Proof of concept for rewritable data contracts
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.11;
import "./utils/Bytecode.sol";
contract CREATE07Proxy {
error ErrorDestroyingContract();
error ErrorDeployingToDeterministicAddress();
function deployDataContract(bytes memory data) external {
@hrkrshnn
hrkrshnn / generic.org
Last active March 19, 2025 23:52
Some generic writeup about common gas optimizations, etc.

Upgrade to at least 0.8.4

Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath).
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For
@miguelmota
miguelmota / decode_example.js
Last active November 8, 2023 14:59
JavaScript decode RLP encoded Ethereum transaction (raw transaction) examples
// RLP encoded transaction
const rawTxHex = '0xed8205fc843b9aca00825208944592d8f8d7b001e72cb26a73e4fa1806a51ac79d88016345785d8a000080808080'
// using rlp package to decode values
const rlp = require('rlp')
const decoded = rlp.decode(rawTxHex)
console.log(decoded)
/*
[ <Buffer 05 fc>,
<Buffer 3b 9a ca 00>,
@lrvick
lrvick / github-troll.md
Last active April 1, 2025 08:14
Trolling Github's DMCA repo with their own security flaws.