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
@EthanNusuiev

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

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