fema-pf-calc 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,41 @@ CACHE_DURATION_MS=7000
|
|
|
193
193
|
|
|
194
194
|
---
|
|
195
195
|
|
|
196
|
+
## Sample Code
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import express from "express";
|
|
200
|
+
import { init, estimateFee } from "fema-pf-calc";
|
|
201
|
+
import { ComputeBudgetProgram } from "@solana/web3.js";
|
|
202
|
+
|
|
203
|
+
const app = express();
|
|
204
|
+
|
|
205
|
+
init({ cluster: "mainnet-beta" }); // no RPC setup needed
|
|
206
|
+
|
|
207
|
+
app.get("/fee", async (req, res) => {
|
|
208
|
+
try {
|
|
209
|
+
const { fee } = await estimateFee({ speed: "fast", strategy: "balanced" });
|
|
210
|
+
|
|
211
|
+
const priorityIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
212
|
+
microLamports: fee,
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
res.json({ fee, priorityIx });
|
|
216
|
+
} catch (err) {
|
|
217
|
+
console.error(err);
|
|
218
|
+
res.status(500).json({ error: err.message });
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
app.listen(8000, () => {
|
|
223
|
+
console.log("Server is running on port http://localhost:8000");
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
export default app;
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
196
231
|
## Project Structure
|
|
197
232
|
|
|
198
233
|
```
|