Skip to content

Instantly share code, notes, and snippets.

View elmariachi111's full-sized avatar
🦜
meow

Stefan Adolf elmariachi111

🦜
meow
View GitHub Profile
@elmariachi111
elmariachi111 / gase_price.1m.py
Created November 14, 2024 20:51
read gas price from etherscan
#!/usr/bin/env python3
import requests
import os
def get_gas_price():
"""
Gets current gas price using the Etherscan API
Returns price in gwei
"""
@elmariachi111
elmariachi111 / LaunchPage.tsx
Created August 28, 2024 20:19
smart contract wallet transaction preparation for Catalyst V2 spawns (Alchemy Account Kit & Gas Policiues / Privy Signer)
import { Button, Flex, Text, useToast } from '@chakra-ui/react'
import { useOnChange } from '@moleculexyz/common'
import { usePrivy } from '@privy-io/react-auth'
import { useRouter } from 'next/router'
import { useCallback, useMemo, useState } from 'react'
import { Address, Chain } from 'viem'
import { Alert } from '@/components/atoms/Alert'
import { BackButton } from '@/components/atoms/BackButton'
import { ContinueButton } from '@/components/atoms/ContinueButton'
export const DEFAULT_CACHE_SECONDS = 15
/**
* We're **not** using upstash or the Vercel KV SDK here to avoid package conflicts
* instead we're using vercel KV's REST API directly: https://vercel.com/docs/storage/vercel-kv/rest-api
*/
const createClient = <T>({ token, url }: { token: string; url: string }) => {
return {
get: async (key: string): Promise<T | null> => {
const result = await (
@elmariachi111
elmariachi111 / SomeStore.sol
Last active August 9, 2024 13:24
The simplest storage based Solana program thinkable.
contract SomeStore {
struct CatalystStorage {
uint64 x;
}
CatalystStorage public stg;
constructor() {
stg = CatalystStorage({x: 0});
}
@elmariachi111
elmariachi111 / INonfungiblePositionManager.sol
Created August 1, 2024 07:38
Provide UniV3 Liquidity between IPTs / ETH
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
/// @notice Creates a new pool if it does not exist, then initializes if not initialized
/// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
/// @param token0 The contract address of token0 of the pool
@elmariachi111
elmariachi111 / Bugbash.t.sol
Last active July 29, 2024 16:59
Catalyst Funding Session
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
import { Test } from "forge-std/Test.sol";
import "forge-std/console.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { LinearCurve } from "../../src/curves/LinearCurve.sol";
import { CurveParametersOutOfRange, TradeType } from "../../src/curves/IIPSeedCurve.sol";
import { CommonTest, Defaults } from "../helpers/CommonTest.sol";
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
import { Test } from "forge-std/Test.sol";
import "forge-std/console.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { LinearCurve } from "../src/curves/LinearCurve.sol";
import { CurveParametersOutOfRange, TradeType } from "../src/curves/IIPSeedCurve.sol";
import { CommonTest, Defaults } from "./helpers/CommonTest.sol";
@elmariachi111
elmariachi111 / configureSIWE.ts
Last active July 14, 2024 22:13
Connectkit Siwe for Next 14 / app router
// Next14 adapted version of https://github.com/family/connectkit/blob/main/packages/connectkit-next-siwe/src/configureSIWE.tsx
import type { IncomingMessage, ServerResponse } from "http";
import {
getIronSession,
IronSession,
SessionOptions as IronSessionOptions,
} from "iron-session";
import { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers";
@elmariachi111
elmariachi111 / useInitiateAuction.tsx
Created September 15, 2023 07:37
rewrite useInitiateAuction for wagmi
'use client'
import { getUnixTime, sub } from 'date-fns'
import { useCallback, useState } from 'react'
import { Address, decodeErrorResult, toHex, zeroAddress } from 'viem'
import { abi } from '@/lib/abi/EasyAuction'
import { useEasyAuctionInitiateAuction } from '@/lib/generated/wagmi/contracts'
import { Transaction } from '@/types/chain'
import { BID_CANCEL_DEADLINE_INTERVAL_HOURS } from '@/utils/auction'
import { currentChain, safeDecodeLogs } from '@/utils/chain'
@elmariachi111
elmariachi111 / gist:9dd638db2e757586943a96fa98ecae5d
Created March 21, 2023 22:50
Chatgpt render and export p5 image
Stefan Adolf
Write a JavaScript program that renders a p5js image of a flower inside a browser context
Sure, here's an example of how to render a flower using p5js in a browser context:
html
Copy code
<!DOCTYPE html>
<html>
<head>