Save auth & order ID (refund & recovery)
:::warning Important Save your auth key and order ID after every Silent Swap. Without them you cannot:
- Refund an expired, unclaimed deposit (get your USDC back from the gateway).
- Recover or prove delivery using the same wallet derived from your mnemonic.
Store them securely (e.g. encrypted backup or password manager) together with the order ID (Base58) and, if applicable, deposit timestamp. :::
What to save
| What | Why |
|---|---|
| Mnemonic (seed phrase) or entropy used for the facilitator group | Refunds are only callable by the refundee address, which is derived from your signer. Recovering the same wallet from the mnemonic restores your ability to call executeRefund. |
| Order ID (Base58, from the order response) | Needed to check status, eligibility, and to execute refund or verify recovery. |
| Deposit timestamp (optional but useful) | Used by checkRecoveryEligibility to know when recovery is available (e.g. 20 minutes after deposit). |
Refund (expired, unclaimed deposit)
If a deposit was never claimed (order stayed OPEN and passed expiration), the refundee can pull the funds back from the gateway. The refundee is the signer address you used when placing the order.
1. Check eligibility
Use checkRefundEligibility from @silentswap/sdk. You need a viem PublicClient on Avalanche and the gateway address.
import { createPublicClient, http } from 'viem';
import { avalanche } from 'viem/chains';
import {
checkRefundEligibility,
ENVIRONMENT_CONFIGS,
ENVIRONMENT,
} from '@silentswap/sdk';
const publicClient = createPublicClient({
chain: avalanche,
transport: http('https://api.avax.network/ext/bc/C/rpc'),
});
const gatewayAddress = ENVIRONMENT_CONFIGS[ENVIRONMENT.MAINNET].s0xGatewayAddress;
const orderId = '...'; // Base58 order ID you saved
const eligibility = await checkRefundEligibility(publicClient, orderId, gatewayAddress);
if (eligibility.refundable) {
console.log('Refund available. Expires at:', eligibility.expiresAt);
// Proceed to executeRefund
} else {
console.log(eligibility.reason);
}2. Execute refund
Only the refundee (the signer address for that order) can send the refund transaction. If you lost the device but have the mnemonic, derive the same EVM account (e.g. m/44'/60'/0'/0/0) and use that wallet to call executeRefund:
import { createWalletClient, http } from 'viem';
import { avalanche } from 'viem/chains';
import { mnemonicToAccount } from 'viem/accounts';
import { executeRefund, ENVIRONMENT_CONFIGS, ENVIRONMENT } from '@silentswap/sdk';
// Recover signer from mnemonic (same derivation as when you placed the order)
const account = mnemonicToAccount(process.env.PRIVATE_SEED!);
const walletClient = createWalletClient({
account,
chain: avalanche,
transport: http(),
});
const gatewayAddress = ENVIRONMENT_CONFIGS[ENVIRONMENT.MAINNET].s0xGatewayAddress;
const orderId = '...'; // Base58 order ID you saved
const txHash = await executeRefund(walletClient, orderId, gatewayAddress);
console.log('Refund tx:', txHash);Extracting mnemonic and recovery paths
The facilitator group used for an order is derived from entropy (obtained when you authenticate). From that entropy you can derive the same mnemonic and paths needed for refund/recovery:
- Mnemonic: Call
exportSecretMnemonicFromEntropy(entropy)from@silentswap/sdk. The function returns an English mnemonic (24 words) derived from the entropy. Store it securely; it allows re-deriving the facilitator keys for that order. - Recovery paths: BIP-44 derivation paths for the group’s public keys. For each facilitator output and each coin type exported by the group (excluding the generic coin type
'*'), the path format is:m/44'/${coinType}'/${accountIndex}'/0/${addressIndex}
whereaccountIndexis the group’s order index (e.g. deposit count when the group was created) andaddressIndexis the output index (0 for a single-output swap). You can build paths from the same key specs used when placing the order (e.g.PublicKeyArgGroups.GENERIC) by callinggroup.exportPublicKeys(outputsCount, keySpecs)and, for each key withcoinType !== '*', addingm/44'/${pk.coinType}'/${accountIndex}'/0/${addressIndex}.
In Node/script flows (e.g. the sol-to-sol swap script), you can return a recoveryInfo object with { mnemonic, recoveryPaths } after the swap so callers can store it for later refund/recovery. The script derives the mnemonic via exportSecretMnemonicFromEntropy(hexToBytes(entropy)) and builds paths from the facilitator group as above. Do not log or commit the mnemonic; only include it in the return value or write it to a secure store.
Recovery (prove delivery / recover flow)
After an order is completed (deposit claimed and funds dispersed), you can use checkRecoveryEligibility to confirm that recovery is available (e.g. after a 20-minute wait). Recovery flows typically use the same mnemonic-derived wallet to prove ownership or to trigger a recovery action in your system.
import {
checkRecoveryEligibility,
queryOrderStatus,
ENVIRONMENT_CONFIGS,
ENVIRONMENT,
} from '@silentswap/sdk';
const publicClient = createPublicClient({ chain: avalanche, transport: http('...') });
const gatewayAddress = ENVIRONMENT_CONFIGS[ENVIRONMENT.MAINNET].s0xGatewayAddress;
const orderId = '...'; // Base58 order ID you saved
const depositTimestamp = 1739...; // ms when deposit was made
const eligible = await checkRecoveryEligibility(
publicClient,
orderId,
gatewayAddress,
depositTimestamp,
20 * 60 * 1000, // 20 min
);
if (eligible) {
// Order is completed and past the wait window; you can run your recovery logic
}You can also use queryOrderStatus to inspect status, expiration, refundee, and amount at any time.
Summary
- Save mnemonic (or entropy), order ID, and viewing auth so you can later track, refund, or recover.
- Mnemonic extraction: Use
exportSecretMnemonicFromEntropy(entropy); build recovery paths asm/44'/${coinType}'/${accountIndex}'/0/${addressIndex}from the group’s public keys (skip coin type'*'). - Refund: Use
checkRefundEligibilitythenexecuteRefundwith a wallet that matches the order’s refundee (recover from mnemonic if needed). - Recovery: Use
checkRecoveryEligibilityandqueryOrderStatuswith the saved order ID; use the mnemonic and paths to restore the same wallet or facilitator keys for any recovery flow.
All of these helpers are exported from @silentswap/sdk (see refund.ts and hd-facilitator-group.ts in the core package).