Solana blockchain SDK for Object Pascal
SolLib4Pascal is a Solana blockchain SDK for Object Pascal, providing JSON RPC clients, wallet management, transaction building, and program interfaces for seamless Solana integration in Object Pascal applications, released under the permissive MIT License.
- Features
- Available Programs
- Getting Started
- Quick Examples
- Running Tests
- Contributing
- Sponsors
- Tip Jar
- License
- Branding
- JSON RPC API -- full coverage of Solana JSON RPC methods
- Streaming JSON RPC API -- WebSocket-based subscription support
- Wallet and accounts -- HD wallet derivation from mnemonic phrases
- Keystore -- secure key storage
- Transaction encoding/decoding -- base64 and wire format support
- Message encoding/decoding -- base64 and wire format support
- Instruction decompilation -- decode instructions back to structured data
- Program interfaces -- typed wrappers for native and SPL programs
System Program
BPF Loader Program
Compute Budget Program | Address Lookup Table Program | Memo Program | Token Program | Token Swap Program | Associated Token Account Program | Shared Memory Program
| Compiler | Minimum Version |
|---|---|
| Delphi | 10.4 or later |
Add the SolLib sources and its dependencies to your compiler search path.
var
LRpc: IRpcClient;
LHttpClient: IHttpApiClient;
LWallet: IWallet;
LFrom: IAccount;
LBlock: IRequestResult<TResponseValue<TLatestBlockHash>>;
LBalance: IRequestResult<TResponseValue<UInt64>>;
LTxBytes: TBytes;
LSignature, LMnemonicWords: string;
LBuilder: ITransactionBuilder;
LPriorityFees: IPriorityFeesInformation;
begin
LHttpClient := THttpApiClient.Create();
LRpc := TClientFactory.GetClient(TCluster.MainNet, LHttpClient);
LMnemonicWords := 'Your Mnemonic Words';
LWallet := TWallet.Create(LMnemonicWords);
LFrom := LWallet.GetAccountByIndex(0);
// Get balance
LBalance := LRpc.GetBalance(LFrom.PublicKey.Key);
if LBalance.WasSuccessful then
Writeln(Format('Balance: %d lamports', [LBalance.Result.Value]))
else
Writeln('Balance: <unavailable>');
LBlock := LRpc.GetLatestBlockHash;
if (LBlock = nil) or (not LBlock.WasSuccessful) or (LBlock.Result = nil) then
raise Exception.Create('Failed to fetch recent blockhash.');
// Build priority fee information
LPriorityFees := TPriorityFeesInformation.Create(
TComputeBudgetProgram.SetComputeUnitLimit(400000), // limit
TComputeBudgetProgram.SetComputeUnitPrice(100000) // price (micro-lamports)
);
// Build transaction (Send a simple memo transaction)
LBuilder := TTransactionBuilder.Create;
LTxBytes :=
LBuilder
.SetRecentBlockHash(LBlock.Result.Value.Blockhash)
.SetFeePayer(LFrom.PublicKey)
.SetPriorityFeesInformation(LPriorityFees)
.AddInstruction(TMemoProgram.NewMemo(LFrom.PublicKey, 'Hello from SolLib'))
.Build(LFrom);
LSignature := LRpc.SendTransaction(LTxBytes);
Writeln(Format('Transaction Signature: %s', [LSignature]));
end;Tests are provided for Delphi.
- Delphi: Open and run
SolLib.Tests/Delphi.Tests/SolLib.Tests.dprin the IDE.
Additional samples can be found in the SolLib.Examples folder.
Contributions are welcome. Please open an issue for bug reports or feature requests, and submit pull requests.
If you find this library useful and would like to support its continued development, tips are greatly appreciated! 🙏
This project is licensed under the MIT License.