https://github.com/maxmmin/sol4j
Java client for Solana web3 RPC API
https://github.com/maxmmin/sol4j
blockchain java library rpc rpc-client sol sol4j solana solana-web3 solana4j web3
Last synced: 3 months ago
JSON representation
Java client for Solana web3 RPC API
- Host: GitHub
- URL: https://github.com/maxmmin/sol4j
- Owner: maxmmin
- License: mit
- Created: 2025-03-24T19:10:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-18T16:39:47.000Z (11 months ago)
- Last Synced: 2025-05-18T17:01:34.399Z (11 months ago)
- Topics: blockchain, java, library, rpc, rpc-client, sol, sol4j, solana, solana-web3, solana4j, web3
- Language: Java
- Homepage: https://central.sonatype.com/artifact/io.github.maxmmin/sol4j
- Size: 518 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Sol4j 👾
[](https://github.com/maxmmin/sol4j/blob/dev/LICENSE)

[](https://solana.com/docs/rpc)
Pure java lib for interacting with Solana RPC API.
The library supports both legacy and versioned transactions and provides a set of core programs for interacting with the Solana blockchain.
Requirements
- Java 11+
Dependencies
- OkHttp
- Jackson
- net.i2p.crypto.eddsa
OutOfBox supported methods
HTTP
Under active development
- getAccountInfo ✅
- getBalance ✅
- getBlock ✅
- getBlockCommitment ✅
- getBlockHeight ✅
- getBlockProduction ✅
- getBlocks ✅
- getBlocksWithLimit ✅
- getBlockTime ✅
- getClusterNodes ✅
- getEpochInfo ✅
- getEpochSchedule ✅
- getFeeForMessage ✅
- getFirstAvailableBlock ✅
- getGenesisHash ✅
- getHealth ✅
- getHighestSnapshotSlot ✅
- getIdentity ✅
- getInflationGovernor ✅
- getInflationRate ✅
- getInflationReward ✅
- getLargestAccounts ✅
- getLatestBlockhash ✅
- getLeaderSchedule ✅
- getMaxRetransmitSlot ✅
- getMaxShredInsertSlot ✅
- getMinimumBalanceForRentExemption ❌
- getMultipleAccounts ✅
- getProgramAccounts ✅
- getRecentPerformanceSamples ❌
- getRecentPrioritizationFees ❌
- getSignaturesForAddress ✅
- getSignatureStatuses ❌
- getSlot ❌
- getSlotLeader ❌
- getSlotLeaders ❌
- getStakeMinimumDelegation ✅
- getSupply ❌
- getTokenAccountBalance ✅
- getTokenAccountsByDelegate ✅
- getTokenAccountsByOwner ✅
- getTokenLargestAccounts ✅
- getTokenSupply ❌
- getTransaction ✅
- getTransactionCount ✅
- getVersion ✅
- getVoteAccounts ❌
- isBlockhashValid ✅
- minimumLedgerSlot ✅
- requestAirdrop ❌
- sendTransaction ✅
- simulateTransaction ❌
WebSocket
Not implemented yet
Getting started
Installation
```xml
io.github.maxmmin
sol4j
1.3.91
```
Creating gateway
```java
RpcGateway rpcGateway = HttpRpcGateway.create("https://api.mainnet-beta.solana.com");
```
Creating RPC Client
```java
RpcClient client = RpcClient.create(rpcGateway);
```
Making requests
```java
List nodes = client.getClusterNodes().send();
```
Multiple encodings support for specific methods
```java
GetTransactionRequest txRequest = client.getTransaction(txSignature);
var defaultEncodedTx = txRequest.send();
BaseEncConfirmedTransaction base58EncodedTx = txRequest.base58();
BaseEncConfirmedTransaction base64EncodedTx = txRequest.base64();
JsonConfirmedTransaction jsonEncodedTx = txRequest.json();
JsonParsedConfirmedTransaction jsonParsedEncTx = txRequest.jsonParsed();
```
Transferring lamports via SystemProgram
```java
Account sender = Account.fromSecretKey(secretKey);
PublicKey receiverPubkey = PublicKey.fromBase58("2ZqPxLUgUFLCyQdqokCNJqnhb4kLY7Bn8T28ABQAjfq4");
BigInteger lamports = BigInteger.valueOf(3000);
Message txMessage = Message.builder()
.addInstruction(SystemProgram.transfer(new SystemProgram.TransferParams(sender.getPublicKey(), receiverPubkey, lamports)))
.setBlockHash(rpcClient.getLatestBlockhash().send().getBlockhash())
.setFeePayer(sender.getPublicKey())
.build();
Transaction transaction = Transaction.build(txMessage, sender);
String txId = rpcClient.sendTransaction(transaction).base64();
```