Skip to content

Instantly share code, notes, and snippets.

@zeuslawyer
Last active July 19, 2023 08:21
Show Gist options
  • Save zeuslawyer/541c941b71df7bba128665d9f7e328bf to your computer and use it in GitHub Desktop.
Save zeuslawyer/541c941b71df7bba128665d9f7e328bf to your computer and use it in GitHub Desktop.
Mempool unblocker
// NOTE THIS IS A HARDHAT SCRIPT. NEEDS A hardhat.config.json file.
const { ethers } = require("hardhat")
async function main() {
const provider = new ethers.providers.JsonRpcProvider(process.env.SEPOLIA_RPC_URL)
const gasPrice = await provider.getGasPrice()
console.log(gasPrice)
const sk1 = process.env.PRIVATE_KEY
const sk2 = process.env.SECOND_PRIVATE_KEY
if (!sk1 || !sk2) {
throw Error(`sk1 or sk2 not defined: "${sk1}" and "${sk2}"`)
}
const DEV1 = new ethers.Wallet(sk1, provider)
const DEV2 = new ethers.Wallet(sk2, provider)
const nonce = await provider.getTransactionCount(DEV1.address, "latest")
console.log("clearing nonce ", nonce)
const tx = {
from: DEV1.address,
to: DEV2.address,
value: ethers.utils.parseUnits("0.0000000001", "ether"),
gasPrice: gasPrice,
gasLimit: ethers.utils.hexlify(1000 * 100), // 10000 gwei
nonce,
}
try {
const transaction = await DEV1.sendTransaction(tx)
console.log("transaction : ", transaction)
} catch (error) {
console.log("\nError in sending Tx: ", error)
throw error
}
}
main()
@zeuslawyer
Copy link
Author

This gist was prepared in connection with this blog:
https://blog.chain.link/upgradable-smart-contracts/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment