I'm trying to get a transaction once mining is done without a random timeout. I've checked similar questions but they aren't conclusive enough.
How do I get a transaction receipt once the mining is done?
Full code on Github.
try {
ethereum
.request({
method: "eth_sendTransaction",
params: [tx],
})
.then(
async (result) =>
{
let nftTxn = await nftContract.safeMint;
console.log("Minting... please wait");
const transactionReceipt = await web3.eth.getTransactionReceipt(result);
await transactionReceipt.wait; //cannot await because of null
if (transactionReceipt!=null) {
console.log(`Mined... ${transactionReceipt}`);
} else { console.log(`error`) }; //getting this
})