Overview
The SDK currently supports specific add-ons from the QuickNode Marketplace with native functions for the add-on's RPC methods.
Supported Add-ons
Priority fee API
QuickNode has a priority fee API, which will fetch the recent priority fees paid across the last (up to) 100 blocks for the entire network or a specific program account. The method qn_estimatePriorityFees returns priority fees in 5% percentiles and convenient ranges (low, medium, high, and extreme).
Additional RPC Functions
sendSmartTransaction
This method will create and send a transaction with priority fees and optimized compute units and a given Keypair.
import { solanaWeb3, Solana } from "@quicknode/sdk";
const { Transaction, SystemProgram, Keypair, PublicKey } = solanaWeb3;
const mainSecretKey = Uint8Array.from([
//redacted
]);
const sender = Keypair.fromSecretKey(mainSecretKey);
const receiver = new PublicKey("redacted");
const senderPublicKey = sender.publicKey;
const endpoint = new Solana({
endpointUrl:
"https://some-cool-name.solana-mainnet.quiknode.pro/redacted",
});
const transaction = new Transaction();
// Add instructions for each receiver
transaction.add(
SystemProgram.transfer({
fromPubkey: senderPublicKey,
toPubkey: receiver,
lamports: 10,
})
);
(async () => {
// Endpoint must added to Priority Fee API to do this
const signature = await endpoint.sendSmartTransaction({
transaction,
keyPair: sender,
feeLevel: "high"
});
console.log(signature);
})().catch(console.error);
prepareSmartTransaction
This method will take a transaction and add a priority fees instruction based on recent network fees and an optimized compute units instruction.
import { solanaWeb3, Solana } from "@quicknode/sdk";
const { Transaction, SystemProgram, Keypair, PublicKey } = solanaWeb3;
const mainSecretKey = Uint8Array.from([
//redacted
]);
const sender = Keypair.fromSecretKey(mainSecretKey);
const receiver = new PublicKey("redacted");
const senderPublicKey = sender.publicKey;
const endpoint = new Solana({
endpointUrl:
"https://some-cool-name.solana-mainnet.quiknode.pro/redacted",
});
const transaction = new Transaction();
// Add instructions for each receiver
transaction.add(
SystemProgram.transfer({
fromPubkey: senderPublicKey,
toPubkey: receiver,
lamports: 10,
})
);
(async () => {
// Endpoint must added to Priority Fee API to do this
const optimizedTransaction = await endpoint.prepareSmartTransaction({
transaction,
payerPublicKey: sender.publicKey,
feeLevel: "high"
});
return optimizedTransaction;
// proceed to sign and send the new optimized transaction
})().catch(console.error);
fetchEstimatePriorityFees
This method will fetch the recent priority fees paid across the last (up to) 100 blocks for the entire network or a specific program account.
import { solanaWeb3, Solana } from "@quicknode/sdk";
const { PublicKey } = solanaWeb3;
const programToSearch = new PublicKey("YOUR_PROGRAM_ID");
const numBlocks = 100;
const endpoint = new Solana({
endpointUrl:
"https://some-cool-name.solana-mainnet.quiknode.pro/redacted",
});
(async () => {
// Endpoint must added to Priority Fee API to do this
const recentPriorityFees = await endpoint.fetchEstimatePriorityFees({
last_n_blocks: numBlocks,
account: programToSearch.toBase58(),
});
return recentPriorityFees;
})().catch(console.error);