So, I’m constantly facing this error and there aren’t much about it except what I already fathom but is not the case, see, I have sufficient balance for gas, and for the eth value to transfer; I kept it 0, but the transaction is still not broadcasting.
To the people who’re thinking what I’m trying to do: I’m actually trying to send unconfirmed transactions of unavialble funds(flasg eth) through eth network(I know there are validity check that I have to bypass, which I will do later, but I’m already stuck in just only broadcasting a legitimate transaction!
const { ethers } = require("ethers");
async function sendTransaction() {
const ethereumNodeUrl = 'https://mainnet.infura.io/v3/085077982f094073a03893b9e3e338ec';
const provider = new ethers.providers.JsonRpcProvider(ethereumNodeUrl);
const senderAddress = '0x0112fa4CB650dCa6eE0f9Bd74106EbB27C382622';
const recipientAddress = '0xA705f5c1dEb081D329EdD2d2ED6817f161Cfd1F0';
const privateKey = 'MY_PVT_KEY';
try {
const wallet = new ethers.Wallet(privateKey, provider);
const tx = {
to: recipientAddress,
value: ethers.utils.parseEther('0'), // Set the value to 0.1 ETH (100 ether in wei)
gasLimit: ethers.utils.hexlify(21000), // Adjust gas limit accordingly
gasPrice: ethers.utils.parseUnits('25', 'gwei'), // Adjust gas price accordingly
};
// Create and broadcast the transaction
const txResponse = await wallet.sendTransaction(tx);
console.log(`Transaction hash: ${txResponse.hash}`);
} catch (error) {
console.error('Error:', error);
}
}
sendTransaction();