Skip to content

Instantly share code, notes, and snippets.

@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();
@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 / .env
Created April 10, 2022 19:23
Get spot prices on Uniswap
INFURA_URL=<your_url>
ETHERSCAN_API_KEY=<your_api_key>
INFURA_URL_TESTNET=<your_url_and_key>
INFURA_URL_TESTNET=
WALLET_ADDRESS=
WALLET_SECRET=
@BlockmanCodes
BlockmanCodes / .env
Created May 3, 2022 21:30
Add liquidity to Uniswap V3
INFURA_URL_TESTNET=
WALLET_ADDRESS=
WALLET_SECRET=
@BlockmanCodes
BlockmanCodes / .env
Last active May 7, 2022 14:40
Decrease Liquidity
INFURA_URL_TESTNET=
WALLET_ADDRESS=
WALLET_SECRET=
@BlockmanCodes
BlockmanCodes / client__package.json
Created May 15, 2022 13:50
Ether Donation Dapp
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.1.3",
"ethers": "^5.6.6",
@BlockmanCodes
BlockmanCodes / .env
Created May 22, 2022 14:31
Uniswap V3 AlphaRouter Example
WALLET_ADDRESS=
WALLET_SECRET=
INFURA_TEST_URL=
@BlockmanCodes
BlockmanCodes / 1_deploy.js
Last active June 21, 2022 12:56
Staking dapp
async function main() {
[signer1, signer2] = await ethers.getSigners();
const Staking = await ethers.getContractFactory('Staking', signer1);
staking = await Staking.deploy({
value: ethers.utils.parseEther('10')
});
console.log("Staking contract deployed to:", staking.address, "by", signer1.address)