https://github.com/soldapper/solana-optimizer
A js class that builds, optimizes, and optionally serializes & base64 encodes a Solana transaction.
https://github.com/soldapper/solana-optimizer
blockchain optimization solana web3
Last synced: about 2 months ago
JSON representation
A js class that builds, optimizes, and optionally serializes & base64 encodes a Solana transaction.
- Host: GitHub
- URL: https://github.com/soldapper/solana-optimizer
- Owner: SolDapper
- License: mit
- Created: 2024-06-24T05:18:00.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-04-02T13:16:06.000Z (about 2 months ago)
- Last Synced: 2025-04-02T14:23:30.708Z (about 2 months ago)
- Topics: blockchain, optimization, solana, web3
- Language: JavaScript
- Homepage:
- Size: 99.6 KB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# solana-optimizer
builds, optimizes, serializes, encodes a solana transaction for both apps and actions
# note
requires a helius rpc as it utilizes the getPriorityFeeEstimate method# example
```javascript
import optimizer from 'solana-optimizer';
// create your instructions and then:
// optimize transaction
const _tx_ = {};
_tx_.rpc = rpc;
_tx_.blink = false; // bool : default false
_tx_.account = payer; // string : required
_tx_.instructions = [instruction]; // array : required
_tx_.signers = false; // array : default false
_tx_.serialize = false; // bool : default false
_tx_.encode = false; // bool : default false
_tx_.table = false; // array : default false
_tx_.tolerance = 1.1; // float : default 1.1
_tx_.compute = true; // bool : default true
_tx_.fees = true; // bool : default true
_tx_.priority = "Medium"; // string : VeryHigh,High,Medium,Low Min
_tx_.memo = "Awesome Memo Man!"; // string : default false
const tx = await optimizer.tx(_tx_);
if(typeof tx.status!="undefined"){console.log(tx);}
else{
const signed = await provider.signTransaction(tx);
const signature = await optimizer.send(rpc,signed);
console.log("signature", signature);
console.log("awaiting status...");
const status = await optimizer.status(rpc,signature);
if(status!="finalized"){console.log("status", status);}
else{console.log(status);}
}
```