Edit:
It looks like I made a mistake when I set up the wallets, feel free to ignore my original message, I think I got it working.
Itās coming from the node.x
I found an article which suggests to increase the gas price at least 10%, which kinda solved the issue, I only get the āreplacement fee too lowā from time to time.
However, sending the transaction to multiple nodes doesnāt seem to be helping. Testing ~10 times, always the last node is the āwinnerā who confirmes the transaction, I assume this is because I increased the gas price.
I was under the impression that it should be random which node includes the transaction.
This way it still takes 2-3 blocks till my tx is confirmed, as it was before when I sent it to 1 node only.
Iām attaching my code, let me know if you see something wrong here. I initialised the wallets with different endpoints - Alchemy, Moralis, QuickNode, Ankr.
const sendTxEthers = async () => {
let nonce = await ethersProvider.getTransactionCount(MY_TEST_ADDRESS);
let tx = {
from: MY_TEST_ADDRESS,
to: MY_ADDRESS,
value: "0x01",
nonce: nonce,
maxPriorityFeePerGas: gasPrice,
maxFeePerGas: (BigNumber.from(gasPrice).mul(2)).toHexString()
}
let txPromise = wallet.sendTransaction(tx);
let txMoralis = getSpeedUpTx(tx);
let txPromiseMoralis = walletMoralis.sendTransaction(txMoralis);
let txQuick = getSpeedUpTx(txMoralis);
let txPromiseQuick = walletQuick.sendTransaction(txQuick);
let txAnkr = getSpeedUpTx(txQuick);
let txPromiseAnkr = walletAnkr.sendTransaction(txAnkr);
// Logging to check which node "won"
txPromise.then((transaction) => {
log("sendTxEthers transaction", transaction);
});
txPromiseMoralis.then((transaction) => {
log("sendTxEthers transaction Moralis", transaction);
});
txPromiseQuick.then((transaction) => {
log("sendTxEthers transaction Quick", transaction);
});
txPromiseAnkr.then((transaction) => {
log("sendTxEthers transaction Ankr", transaction);
});
}
// Multiple gas by 1.2
const getSpeedUpTx = (tx) => {
let txCopy = JSON.parse(JSON.stringify(tx));
txCopy.maxPriorityFeePerGas = BigNumber.from(txCopy.maxPriorityFeePerGas).mul(12).div(10).toHexString();
txCopy.maxFeePerGas = BigNumber.from(txCopy.maxFeePerGas).mul(12).div(10).toHexString();
return txCopy;
}