Skip to content

Instantly share code, notes, and snippets.

@BlockmanCodes
BlockmanCodes / .env
Created April 10, 2022 19:23
Get spot prices on Uniswap
INFURA_URL=<your_url>
ETHERSCAN_API_KEY=<your_api_key>
@BlockmanCodes
BlockmanCodes / getAbi.js
Created April 7, 2022 12:26
Get a contract ABI programmatically with the Etherscan API
const axios = require('axios')
const { ethers } = require('ethers')
const address = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'
const apiKey = ''
const url = `https://api.etherscan.io/api?module=contract&action=getabi&address=${address}&apikey=${apiKey}`
const infuraUrl = ''
const getAbi = async () => {
const res = await axios.get(url)
@BlockmanCodes
BlockmanCodes / Staking.js
Created April 3, 2022 12:40
Deposit and withdraw ERC20 tokens (USDT, SHIB, MATIC) from a Solidity contract (Hardhat, Ethers.js)
const { expect } = require("chai");
describe('Staking', function () {
beforeEach(async function() {
[owner, wallet1, wallet2] = await ethers.getSigners();
Staking = await ethers.getContractFactory('Staking', owner);
Wbtc = await ethers.getContractFactory('Wbtc', wallet1);
staking = await Staking.deploy();
wbtc = await Wbtc.deploy();