Skip to content

Instantly share code, notes, and snippets.

@BlockmanCodes
BlockmanCodes / Curl
Last active July 11, 2022 19:47
Forking mainnet
curl --location --request POST 'localhost:8545/' --header 'Content-Type: application/json' --data-raw '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
@BlockmanCodes
BlockmanCodes / getPriceOracle.js
Last active July 12, 2024 07:57
Uniswap V3 Price Oracle in JavaScript
const { ethers } = require('ethers')
// IMPORTS AND SETUP
const JSBI = require('jsbi') // [email protected]
const { abi: IUniswapV3PoolABI } = require("@uniswap/v3-core/artifacts/contracts/interfaces/IUniswapV3Pool.sol/IUniswapV3Pool.json");
const { TickMath, FullMath } = require('@uniswap/v3-sdk')
require('dotenv').config()
const POOL_ADDRESS = '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640'
@BlockmanCodes
BlockmanCodes / createUniswapPool.js
Last active August 19, 2023 18:53
Deploy Uniswap V3 Pool Ropsten
// SETUP
const { ethers } = require('ethers')
const axios = require('axios')
require('dotenv').config()
const UNISWAP_V3_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984'
const ROPSTEN_PROVIDER = new ethers.providers.JsonRpcProvider(process.env.INFURA_URL_ROPSTEN)
const WALLET_ADDRESS = process.env.WALLET_ADDRESS
@BlockmanCodes
BlockmanCodes / hardhat.config.js
Created August 14, 2022 19:53
Pausable Token
require("@nomiclabs/hardhat-waffle");
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.9",
};
.App {
background-color: #2B2D3C;
text-align: center;
min-height: 100vh;
padding-top: 25px;
padding-bottom: 25px
}
/*////////////////////////////////////////////////////////////////////////////*/
/* Nav Bar */
@BlockmanCodes
BlockmanCodes / Crowdsale.js
Created September 8, 2022 00:50
Crowdsale
const { expect } = require("chai");
describe('Staking', () => {
beforeEach(async () => {
[owner, signer2, signer3] = await ethers.getSigners();
RexCoin = await ethers.getContractFactory('RexCoin', owner);
rexCoin = await RexCoin.deploy();
Crowdsale = await ethers.getContractFactory('Crowdsale', owner);
@BlockmanCodes
BlockmanCodes / client__package.json
Last active September 23, 2023 07:29
Airdrop app
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.2.1",
"buffer": "^6.0.3",
@BlockmanCodes
BlockmanCodes / WETH9.json
Created October 6, 2022 12:50
wrap and unwrap ether
{
"bytecode": "60606040526040805190810160405280600d81526020017f57726170706564204574686572000000000000000000000000000000000000008152506000908051906020019061004f9291906100c8565b506040805190810160405280600481526020017f57455448000000000000000000000000000000000000000000000000000000008152506001908051906020019061009b9291906100c8565b506012600260006101000a81548160ff021916908360ff16021790555034156100c357600080fd5b61016d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061010957805160ff1916838001178555610137565b82800160010185558215610137579182015b8281111561013657825182559160200191906001019061011b565b5b5090506101449190610148565b5090565b61016a91905b8082111561016657600081600090555060010161014e565b5090565b90565b610c348061017c6000396000f3006060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b9578063095ea7b31461014757806318160ddd146101a157806323b872dd146101ca5780632e1a7d4d14610243578063313ce5671461026657806370a
@BlockmanCodes
BlockmanCodes / WETH9.json
Created October 10, 2022 20:57
Estimate Gas Usage
{
"bytecode": "60606040526040805190810160405280600d81526020017f57726170706564204574686572000000000000000000000000000000000000008152506000908051906020019061004f9291906100c8565b506040805190810160405280600481526020017f57455448000000000000000000000000000000000000000000000000000000008152506001908051906020019061009b9291906100c8565b506012600260006101000a81548160ff021916908360ff16021790555034156100c357600080fd5b61016d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061010957805160ff1916838001178555610137565b82800160010185558215610137579182015b8281111561013657825182559160200191906001019061011b565b5b5090506101449190610148565b5090565b61016a91905b8082111561016657600081600090555060010161014e565b5090565b90565b610c348061017c6000396000f3006060604052600436106100af576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde03146100b9578063095ea7b31461014757806318160ddd146101a157806323b872dd146101ca5780632e1a7d4d14610243578063313ce5671461026657806370a
@BlockmanCodes
BlockmanCodes / Setup
Created October 16, 2022 01:13
Uniswap V3 Multicall
const { abi: V3SwapRouterABI } = require('@uniswap/v3-periphery/artifacts/contracts/interfaces/ISwapRouter.sol/ISwapRouter.json')
const { abi: PeripheryPaymentsABI } = require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IPeripheryPayments.sol/IPeripheryPayments.json");
const { abi: MulticallABI } = require("@uniswap/v3-periphery/artifacts/contracts/interfaces/IMulticall.sol/IMulticall.json");
const V3SwapRouterAddress = '0xE592427A0AEce92De3Edee1F18E0157C05861564'
const WETHAddress = '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6';
const USDCAddress = '0x07865c6E87B9F70255377e024ace6630C1Eaa37F';
const UNIADDRESS = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984';