From 2e31237a9eab425d1bd30a98e77c22dc17de685a Mon Sep 17 00:00:00 2001 From: SDargarh Date: Tue, 23 Jul 2024 19:22:58 +0530 Subject: [PATCH] Added functionality to accept priority fee for a transaction --- CHANGELOG.md | 3 ++- src/helper/generateTransactionObject.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2627ffe..466793c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,4 +10,5 @@ - Added get balance method to fetch SOL balance of an account - Added functionality to sign SOL and fungible tokens transfer transaction - Added functionality to broadcast a signed transaction -- Added functionality to get estimated fee for a transaction \ No newline at end of file +- Added functionality to get estimated fee for a transaction +- Added functionality to accept priority fee for a transaction \ No newline at end of file diff --git a/src/helper/generateTransactionObject.js b/src/helper/generateTransactionObject.js index e3245e3..f4809d7 100644 --- a/src/helper/generateTransactionObject.js +++ b/src/helper/generateTransactionObject.js @@ -48,6 +48,15 @@ async function generateTransactionObject(transaction, signer, connection) { ); } + // set the desired priority fee in microLamport + if(transaction?.priorityFee && transaction?.priorityFee > 0) { + const addPriorityFee = solanaWeb3.ComputeBudgetProgram.setComputeUnitPrice({ + microLamports: transaction.priorityFee, + }); + + rawTransaction.add(addPriorityFee); + } + return rawTransaction; }