Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrying an EIP 1559 transaction #7447

Open
EthanNusuiev opened this issue Jan 20, 2025 · 2 comments
Open

Retrying an EIP 1559 transaction #7447

EthanNusuiev opened this issue Jan 20, 2025 · 2 comments

Comments

@EthanNusuiev
Copy link

After sending a transaction and getting error (that expected behavior for some transactions):
'Transaction was not mined within 100 seconds. Please make sure your transaction was properly sent and there are no previous pending transaction for the same account. However, be aware that it might still be mined
`

then Im trying to retrying the transaction with bigger maxPriorityFeePerGas and maxFeePerGas but still cant and getting this error:
`'Returned error: replacement transaction underpriced'
even if Im increase by 100%

async increaseTimeoutTransaction(
payload: ValidateTimeoutTransactionDtoByAssetDto,
previousTransaction: GetTransactionResponse,
requestId: string
): Promise {
const { increaseGasRate } = payload;
const { gas, maxPriorityFeePerGas, nonce } = previousTransaction;
const transferFromMethodABI = await this.getTransferFromAbiMethod(payload, requestId);
let newMaxPriorityFeePerGas = new Decimal(maxPriorityFeePerGas).multiply(increaseGasRate).toString();
newMaxPriorityFeePerGas = Utils.truncate(newMaxPriorityFeePerGas, 0).toString();
const currentBaseFee = await this.infuraApiService.getBaseFee(payload.blockchain, requestId); //Get the base fee from latest block
const newMaxFeePerGas = new Decimal(currentBaseFee).plus(newMaxPriorityFeePerGas).toString();
const signTransactionDto: SignTransactionApiDto = {
from: payload.spenderWalletAddress,
to: payload.contractAddress,
blockchain: payload.blockchain,
data: transferFromMethodABI,
nonce,
gas,
maxFeePerGas: newMaxFeePerGas,
maxPriorityFeePerGas: newMaxPriorityFeePerGas,
type: 2, // EIP-1559 transaction type
};
return this.signAndSendTransaction(signTransactionDto, requestId);
}

Versions used of:
npm: v10.8.1,
Node: v20.16.0,
web3.js: 4.16.0 ,
OS: macOs sequoia 15.2,
device: mac

@jdevcs
Copy link
Contributor

jdevcs commented Jan 21, 2025

Make sure you correctly calculate the maxFeePerGas and maxPriorityFeePerGas based on real-time network conditions. Try using https://docs.web3js.org/guides/transactions/gas-and-fees#calculating-fees for calculating fee and adjust by increasing baseFeePerGasFactor param.

@jdevcs
Copy link
Contributor

jdevcs commented Jan 21, 2025

Also you may be aware, we are in the process of sunsetting Web3.js, Our focus during this transition will be on addressing critical issues to ensure a smooth migration for our users.
For further details regarding the sunsetting of Web3.js, please refer to the official announcement here: Web3.js Sunset Announcement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@EthanNusuiev @jdevcs and others