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
# pragma version ^0.3.10
"""
@title P256 Signature Verification Function
@custom:contract-name P256Verifier
@license GNU Affero General Public License v3.0 only
@author pcaversaccio
@notice The `verify` function can be used to natively (currently
only supported on Polygon Mumbai test network) verify a
P256 (a.k.a. secp256r1 elliptic curve) signature. For more
technical details, please refer to EIP-7212:
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/math/SafeMath.sol
// Original license: SPDX_License_Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
@pcaversaccio
pcaversaccio / README.md
Last active November 18, 2023 16:52
Set up the vast.ai instance with profanity2 (https://github.com/1inch/profanity2).

Setup

Update Linux

sudo apt update && sudo apt upgrade

Install build-essential Packages

@pcaversaccio
pcaversaccio / compute_create2_address_zksync.vy
Last active May 15, 2024 07:19
Calculate the `CREATE2` address on zkSync using Vyper.
# @version ^0.3.10
_CREATE2_PREFIX: constant(bytes32) = 0x2020dba91b30cc0006188af794c2fb30dd8520db7e2c088b7fc7c103c00ca494
@external
@pure
def compute_create2_address_zksync(salt: bytes32, bytecode_hash: bytes32, deployer: address, input: Bytes[4_096]=b"") -> address:
constructor_input_hash: bytes32 = keccak256(input)
@pcaversaccio
pcaversaccio / ERC2098.vy
Created July 17, 2023 15:41
A Vyper utility function that transforms a standard signature into an EIP-2098 (https://eips.ethereum.org/EIPS/eip-2098) compliant signature.
# @version ^0.3.9
@internal
@pure
def _to_2098_format(signature: Bytes[65]) -> Bytes[64]:
"""
@dev Transforms a standard signature into an EIP-2098
(https://eips.ethereum.org/EIPS/eip-2098) compliant
signature.
@param signature The secp256k1 64/65-bytes signature.
@pcaversaccio
pcaversaccio / to_checksum_name.py
Last active June 15, 2023 09:10
A Python script that converts a function name into a name convention based on a checksum approach.
from re import sub
from eth_utils import keccak
from caseconverter import camelcase, flatcase, macrocase, pascalcase, snakecase
"""
Biased Assumption: Every single word of an interface function, event or custom error definition,
or anything else contained in an interface definition and used as an identifier, is capitalised
and concatenated with an underscore before running `to_checksum_name`.
Examples: `TRANSFER_FROM`, `BALANCE_OF`, `$I_HATE_PHP`.
@pcaversaccio
pcaversaccio / bootnodes.txt
Last active May 4, 2023 10:52
An overview of the current IPs and locations of the CL bootnodes.
# CL mainnet bootnodes: https://github.com/eth-clients/eth2-networks/blob/master/shared/mainnet/bootstrap_nodes.txt.
### ENR
# Teku team's bootnodes
enr:-KG4QOtcP9X1FbIMOe17QNMKqDxCpm14jcX5tiOE4_TyMrFqbmhPZHK_ZPG2Gxb1GE2xdtodOfx9-cgvNtxnRyHEmC0ghGV0aDKQ9aX9QgAAAAD__________4JpZIJ2NIJpcIQDE8KdiXNlY3AyNTZrMaEDhpehBDbZjM_L9ek699Y7vhUJ-eAdMyQW_Fil522Y0fODdGNwgiMog3VkcIIjKA
enr:-KG4QL-eqFoHy0cI31THvtZjpYUu_Jdw_MO7skQRJxY1g5HTN1A0epPCU6vi0gLGUgrzpU-ygeMSS8ewVxDpKfYmxMMGhGV0aDKQtTA_KgAAAAD__________4JpZIJ2NIJpcIQ2_DUbiXNlY3AyNTZrMaED8GJ2vzUqgL6-KD1xalo1CsmY4X1HaDnyl6Y_WayCo9GDdGNwgiMog3VkcIIjKA
# Prylab team's bootnodes
enr:-Ku4QImhMc1z8yCiNJ1TyUxdcfNucje3BGwEHzodEZUan8PherEo4sF7pPHPSIB1NNuSg5fZy7qFsjmUKs2ea1Whi0EBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQOVphkDqal4QzPMksc5wnpuC3gvSC8AfbFOnZY_On34wIN1ZHCCIyg
@pcaversaccio
pcaversaccio / isqrt.ipynb
Last active April 30, 2023 15:42
Example Jupyter Notebook using https://try.vyperlang.org.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pcaversaccio
pcaversaccio / ReadNestedStruct.sol
Created April 24, 2023 16:33
Access nested struct withing Solidity.
// SPDX-License-Identifier: WTFPL
pragma solidity ^0.8.19;
contract NestedStruct {
struct Inside {
address a1;
address a2;
address a3;
}
@pcaversaccio
pcaversaccio / Unreachable.sol
Created April 24, 2023 12:48
Always remember that `address(this).balance` includes also `msg.value` of the current transaction.
// SPDX-License-Identifier: WTFPL
pragma solidity ^0.8.19;
contract TryToReachMe {
constructor() payable {
assert(msg.value == 1 wei);
}
function tryMeBabe(address addr) public payable {
uint256 balance = address(this).balance;