Skip to content

Instantly share code, notes, and snippets.

View RareSkills's full-sized avatar

RareSkills RareSkills

View GitHub Profile
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;

contract Bank {

    mapping(address => uint256) public balances;

    constructor() payable {
 require(msg.value == 2 ether);
from ecpy.curves import Curve
from ecpy.keys import ECPublicKey, ECPrivateKey
from sha3 import keccak_256
private_key = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
cv = Curve.get_curve('secp256k1')
pv_key = ECPrivateKey(private_key, cv)
pu_key = pv_key.get_public_key()
from ecpy.curves import Curve
from sha3 import keccak_256
private_key = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
cv = Curve.get_curve('secp256k1')
pu_key = private_key * cv.generator # just multiplying the private key by generator point (EC multiplication)
concat_x_y = pu_key.x.to_bytes(32, byteorder='big') + pu_key.y.to_bytes(32, byteorder='big')
eth_addr = '0x' + keccak_256(concat_x_y).digest()[-20:].hex()
contract MinimalProxyFactory {
    
    address[] public proxies;

    function deployClone(address _implementationContract) external returns (address) {
        // convert the address to 20 bytes
        bytes20 implementationContractInBytes = bytes20(_implementationContract);
        //address to assign a cloned proxy
        address proxy;
const hre = require("hardhat");
async function main() {
const ImplementationContract = await hre.ethers.getContractFactory(
"ImplementationContract"
);
// deploy the implementation contract
const implementationContract = await ImplementationContract.deploy();
await implementationContract.deployed();
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.19;
// optimizer = 200
// sum cannot be unchecked because the array sum can overflow
// function name must be the same because function names can alter the gas cost
// You will need to comment out one of the functions to make the code compile

contract Loops {
 // [1,2,3,4,5,6,7,8,9,10] -> 2100 gas
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";

contract ERC20Implementation is ERC20Upgradeable {
    // get ERC20 name from the metadata
    function name()
        public
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC20Implementation.sol";
import "./MetaProxyFactory.sol";

contract ERC20MetaProxyFactory is MetaProxyFactory {
    address[] public proxyAddresses;

 function createClone(
const hre = require("hardhat");
async function main() {
const ERC20ProxyFactory = await hre.ethers.getContractFactory(
"ERC20MetaProxyFactory"
);
const erc20ProxyFactory = await ERC20ProxyFactory.deploy();
// deploy the erc20 proxy factory contract
await erc20ProxyFactory.deployed();
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

contract Verifier {
    using ECDSA for bytes32;

    address public verifyingAddress;