Reputation: 23
I'm using Alchemy as Web3 Provider for deploying my Smart Contract with Hardhat. It stops when when its deploying the contract after it deployed the factory of the contract. (Ropsten Testnet)
const hre = require("hardhat"); //import the hardhat
async function main() {
console.log("[4] Getting Deployer")
const [deployer] = await ethers.getSigners(); //get the account to deploy the contract
console.log("[+] Deploying contracts with the account:", deployer.address);
console.log("[3] Getting Factory")
const Factory = await hre.ethers.getContractFactory(
"BlockchainNamingService"
); // Getting the Contract
console.log("[2] Getting Smart Contract")
const smartContract = await Factory.deploy(); //deploying the contract
console.log("[1] Deploying Smart Contract")
await smartContract.deployed(); // waiting for the contract to be deployed
console.log("[FINISHED] Contract deployed to:", smartContract.address); // Returning the contract address on the rinkeby
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
}); // Calling the function to deploy the contract
npx hardhat run scripts/deploy.js --network ropsten
Is there a problem on the network, on my contract or deploy script?
Upvotes: 2
Views: 1478
Reputation: 121
The deploy transaction is most likely stuck due to a low gas fee.
You can set the gasPrice to a sufficient value in hardhat config
networks: {
goerli: {
url: API_URL,
accounts: [PRIVATE_KEY],
gasPrice: 30000000000, // this is 30 Gwei
},
},
What will also happen when a transaction is stuck is that new transactions will not be confirmed before the stuck transaction is resolved. In this case the pending transaction can be overwritten by sending a new transaction with the same nonce. You can see pending transactions and their nonces in alchemy dashboards mempool tab.
The nonce can be set in the deploy function:
await Factory.deploy({nonce: 5})
Upvotes: 4