Skip to content

Instantly share code, notes, and snippets.

View korrio's full-sized avatar
👽

kOrriO korrio

👽
  • Hal Finney Co.,Ltd.
  • mempool
  • X @korrio
View GitHub Profile
@korrio
korrio / pancake.js
Created June 29, 2021 06:54
pancake.js
const ethers = require(`ethers`)
const { ChainId, Token, TokenAmount, Fetcher, Pair, Route, Trade, TradeType, Percent } =
require(`@pancakeswap-libs/sdk`);
const Web3 = require(`web3`);
const { JsonRpcProvider } = require("@ethersproject/providers");
require(“dotenv”).config()
const provider = new JsonRpcProvider(`https://bsc-dataseed1.binance.org/`);
const web3 = new Web3(`wss://apis.ankr.com/wss/c40792ffe3514537be9fb4109b32d257/946dd909d324e5a6caa2b72ba75c5799/binance/full/main`);
@korrio
korrio / bot.js
Created June 28, 2021 10:10
bot.js
import ethers from 'ethers';
import express from 'express';
import chalk from 'chalk';
const app = express();
// TUK-KKUB LP on Vonder: 0xFB74CAc28EE2635F08C22800CCFD5200cDe52DDF
const WETH = 'KKUB';
const ERC20 = 'TUK';
const data = {
@korrio
korrio / wrapUnwrap.js
Created June 19, 2021 05:30
wrapUnwrap.js
export default function useWrapCallback(
inputCurrency: Currency | undefined,
outputCurrency: Currency | undefined,
typedValue: string | undefined
): { wrapType: WrapType; execute?: undefined | (() => Promise<void>); inputError?: string } {
const { chainId, account } = useActiveWeb3React()
const wethContract = useWETHContract()
const balance = useCurrencyBalance(account ?? undefined, inputCurrency)
// we can always parse the amount typed as the input currency, since wrapping is 1:1
const inputAmount = useMemo(() => tryParseAmount(typedValue, inputCurrency), [inputCurrency, typedValue])
@korrio
korrio / chainId.ts
Created June 16, 2021 08:26
chainId.ts
export enum ChainId {
Mainnet = 1,
Ropsten = 3,
Rinkeby = 4,
Goerli = 5,
Kovan = 42,
BSC = 56,
xDai = 100,
Polygon = 137,
Mumbai = 80001,
@korrio
korrio / SimpleBank.sol
Created June 16, 2021 06:35
SimpleBank.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
@korrio
korrio / voted.sol
Created June 15, 2021 09:15
voted.sol
/**
*Submitted for verification at Etherscan.io on 2019-05-27
*/
pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;
// specifies what version of compiler this code will be compiled with
contract Voting {
/* the mapping field below is equivalent to an associative array or hash.
@korrio
korrio / Bank.sol
Created June 15, 2021 06:10
Bank.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/// @title Bank
/// @author nemild, kor, tot
/* 'contract' has similarities to 'class' in other languages (class variables,
inheritance, etc.) */
@korrio
korrio / sendTransaction.js
Created June 11, 2021 10:31
sendTransaction.js
const drawing = async (privateKey) => {
console.log('Drawing...');
const address = getUserAddress(privateKey);
const nonce = await web3.eth.getTransactionCount(address);
const gasPriceWei = await web3.eth.getGasPrice();
const randomHex = Web3.utils.randomHex(32).substr(2);
const randomNumber = new BN(randomHex, 16).toString();
const data = LotteryContract.methods.drawing(randomNumber).encodeABI();
const signedTx = await web3.eth.accounts.signTransaction({
to: contractAddress,
➜ erc20-snapshot git:(master) ✗ node index.js
Error: overflow (fault="overflow", operation="toNumber", value="35000214728014336407470934256024915466671168103574785725052718905953538277376", code=NUMERIC_FAULT, version=bignumber/5.3.0)
at Logger.makeError (/Users/aq1/Desktop/init/snapshot/erc20-snapshot/node_modules/@ethersproject/logger/lib/index.js:187:21)
at Logger.throwError (/Users/aq1/Desktop/init/snapshot/erc20-snapshot/node_modules/@ethersproject/logger/lib/index.js:196:20)
at throwFault (/Users/aq1/Desktop/init/snapshot/erc20-snapshot/node_modules/@ethersproject/bignumber/lib/bignumber.js:305:19)
at BigNumber.toNumber (/Users/aq1/Desktop/init/snapshot/erc20-snapshot/node_modules/@ethersproject/bignumber/lib/bignumber.js:153:13)
at /Users/aq1/Desktop/init/snapshot/erc20-snapshot/node_modules/@ethersproject/abi/lib/coders/array.js:89:60
at Array.forEach (<anonymous>)
at Object.unpack (/Users/aq1/Desktop/init/snapshot/erc20-snapshot/node_modules/@ethersproject/abi/lib/coders/
@korrio
korrio / pancakeswap.json
Created May 27, 2021 15:07
pancakeswap.json
{
"name": "PancakeSwap Default List",
"timestamp": "2021-03-17T09:56:23Z",
"version": {
"major": 2,
"minor": 7,
"patch": 0
},
"tags": {},
"logoURI": "https://exchange.pancakeswap.finance/images/pancakeswap.png",