Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Retrying an EIP 1559 transaction #7447

Open

Description

@EthanNusuiev

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

Activity

  1. jdevcs commented on Jan 21, 2025

    @jdevcs
    Contributor

    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.

  2. jdevcs commented on Jan 21, 2025

    @jdevcs
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions