Retry Transactions
Replace stuck transactions by preparing and sending calls again.
Key use cases:
- Replace transactions stuck due to low gas prices
- Speed up pending transactions by increasing gas fees
- Override transactions that have been pending for too long
- Cancel stuck transactions by replacing with a no-op
The Retry flow
- Send the initial transaction
- Monitor the transaction status
- If the transaction is stuck/pending too long, re-prepare the same call
- Send the transaction with higher gas to replace the stuck transaction
- The original transaction gets dropped from mempool
Prerequisites
- An Alchemy API Key
- A Gas Manager policy
- A signer to own the account and sign messages
If the original transaction is already being mined, the replacement transaction may be dropped. In this case, you won’t be able to retrieve data using the replacement’s call ID, and the original transaction will be included!
JavaScript
API
Required SDK version: ^v4.61.0
See the sendCalls SDK
reference
for full descriptions of the parameters used in the following example.
When re-sending calls without a nonceOverride, the client automatically uses the same nonce as the pending transaction, replacing it.
You’ll need the following env variables:
ALCHEMY_API_KEY: An Alchemy API KeyALCHEMY_POLICY_ID: A Gas Manager policy IDPRIVATE_KEY: A private key for a signer