I created an ERC1155 with Hardhat v2.15 and deployed it to the mainnet. However, it got stuck in mempool due to very low gas price. I didn't notice I set it to 35 gwei when the network gas price was about ~200 gwei.
Now I want to set the same nonce and re-deploy the contract with a higher gas price. I couldn't find a way to set the nonce upon deployment though, unlike sending transactions via web3js where I can just add { nonce: 123 }
.
Here is my current deploy.ts
import { ethers, network } from "hardhat";
import * as dotenv from "dotenv";
dotenv.config({ path: __dirname+'/.env' });
// Types
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
async function main() {
// Provider
const provider = ethers.provider;
let deployer: any;
let ownerAddress: string;
// Wallets & addresses
if (network.name === "localhost") {
let owner: HardhatEthersSigner;
[deployer, owner] = await ethers.getSigners();
ownerAddress = owner.address;
} else {
deployer = new ethers.Wallet(process.env.PRIVATE_KEY || "private-key", provider);
ownerAddress = process.env.OWNER_ADDRESS || "owner-address";
}
console.log("Network name: ", network.name);
console.log("Deployer: ", deployer.address);
console.log("Deployer balance: ", (await provider.getBalance(deployer)).toString());
console.log("Nonce (latest): ", await provider.getTransactionCount(deployer, 'latest'));
console.log("Nonce (pending): ", await provider.getTransactionCount(deployer, 'pending'));
// Deploy contract
const token = await ethers.deployContract("Token", ['some-args']);
await tokenizedBond.waitForDeployment(); // Something I can add here to set nonce?
console.log("Deployed at ", tokenizedBond.target);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});