Hello,
When trying to use Drift SDK to place a perp order, I randomly have the following error, even if the perp order is correctly placed :
Error: Simulation failed.
Message: Transaction simulation failed: This transaction has already been processed.
Logs:
[].
Catch the SendTransactionError and call getLogs() on it for full details.
at pQ.sendEncodedTransaction (.next/server/chunks/[root-of-the-server]__dadf0127..js:8:67131)
at async pQ.sendRawTransaction (.next/server/chunks/[root-of-the-server]__dadf0127..js:8:66650) {
signature: '',
transactionMessage: 'Transaction simulation failed: This transaction has already been processed',
transactionLogs: []
}
Here is my code :
// DriftClient init:
const provider = new AnchorProvider(
connection,
wallet,
{
commitment: 'confirmed',
preflightCommitment: 'confirmed',
skipPreflight: false,
}
);
const driftPublicKey = new PublicKey(sdkConfig.DRIFT_PROGRAM_ID);
const driftClient = new DriftClient({
connection: provider.connection,
wallet: provider.wallet,
programID: driftPublicKey,
accountSubscription: {
type: "websocket",
}
});
await driftClient.subscribe();
// Perp placing order
try {
await driftClient.placePerpOrder(
getMarketOrderParams({
marketIndex: marketIndex,
baseAssetAmount: assetAmount,
direction: direction,
}),
undefined,
subAccountId
);
} catch (e) {
if (e instanceof SendTransactionError) {
console.error(e.logs);
}
throw e;
}
I'm using NextJS 16 and latest @drift-labs/sdk 2.157.0-beta.7.
Can you please advice.
Hello,
When trying to use Drift SDK to place a perp order, I randomly have the following error, even if the perp order is correctly placed :
Here is my code :
I'm using NextJS 16 and latest @drift-labs/sdk 2.157.0-beta.7.
Can you please advice.