Documentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
getCheckoutTransaction
Fetches the current state of a checkout transaction. Use this to poll for status updates after submitting a transaction, or to restore transaction state on page reload.
Usage
import { getCheckoutTransaction } from '@dynamic-labs-sdk/client';
const transaction = await getCheckoutTransaction({
transactionId: 'txn_abc123',
});
console.log('Execution state:', transaction.executionState);
console.log('Settlement state:', transaction.settlementState);
Parameters
| Parameter | Type | Description |
|---|
transactionId | string | The checkout transaction ID returned by createCheckoutTransaction. |
Returns
Promise<CheckoutTransaction> - The current transaction state.
Execution States
| State | Description |
|---|
pending | Transaction has been created but not yet signed |
signing | Transaction is being signed by the wallet |
broadcasted | Transaction has been broadcast to the blockchain |
source_confirmed | Source chain has confirmed the transaction |
cancelled | Transaction was cancelled before broadcast |
expired | Transaction expired before completion |
failed | Transaction failed during execution |
Settlement States
| State | Description |
|---|
none | No settlement in progress |
bridging | Funds are being bridged across chains |
routing | Transaction is being routed through a DEX |
settling | Funds are settling to the destination |
swapping | Token swap is in progress |
completed | Settlement is complete |
failed | Settlement failed |
Examples
Poll for completion
import { getCheckoutTransaction } from '@dynamic-labs-sdk/client';
const TERMINAL_STATES = ['cancelled', 'expired', 'failed'];
const TERMINAL_SETTLEMENT = ['completed', 'failed'];
const pollTransaction = async (transactionId) => {
const poll = async () => {
const tx = await getCheckoutTransaction({ transactionId });
if (
TERMINAL_STATES.includes(tx.executionState) ||
TERMINAL_SETTLEMENT.includes(tx.settlementState)
) {
return tx;
}
// Wait 3 seconds and poll again
await new Promise((resolve) => setTimeout(resolve, 3000));
return poll();
};
return poll();
};
const finalTx = await pollTransaction('txn_abc123');
console.log('Final state:', finalTx.settlementState);
Restore transaction on page reload
import { getCheckoutTransaction } from '@dynamic-labs-sdk/client';
const restoreCheckout = async () => {
const storedId = localStorage.getItem('checkoutTransactionId');
if (!storedId) return null;
try {
const transaction = await getCheckoutTransaction({
transactionId: storedId,
});
return transaction;
} catch {
// Transaction no longer valid
localStorage.removeItem('checkoutTransactionId');
return null;
}
};