Mempool unblocker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist was prepared in connection with this blog:
https://blog.chain.link/upgradable-smart-contracts/