lightsail-network/java-stellar-sdk/java-stellar-sdk
Claude Code and agent skill by lightsail-network/java-stellar-sdk
- community
Checking that the SKILL.md file is still in the repository.
Build Stellar blockchain applications in Java using stellar-sdk (network.lightsail:stellar-sdk). Use for transaction building, signing, Horizon queries, Soroban RPC, smart contract deployment/invocation, XDR/SCVal conversion, and SEP integrations.
Install
npx vskill@latest install lightsail-network/java-stellar-sdk/java-stellar-sdkSKILL.md
Stellar Java SDK (network.lightsail:stellar-sdk)
Write correct Java for the Stellar network using the stellar-sdk package. This file is self-contained; load a file from references/ only when the task needs that topic.
Install
Maven:
Gradle:
Import style
Public APIs live under org.stellar.sdk; operations under org.stellar.sdk.operations; the contract helpers under org.stellar.sdk.contract; SCVal helpers under org.stellar.sdk.scval; exceptions under org.stellar.sdk.exception, with the high-level contract-client exceptions under org.stellar.sdk.contract.exception.
Clients
Server— Horizon client. Seereferences/horizon.md.SorobanServer— Soroban RPC client (Closeable). Seereferences/soroban.md.ContractClient— high-level Soroban contract client (Closeable) that wraps the
simulate → prepare → sign → submit flow. See references/soroban.md.
The SDK is synchronous (built on OkHttp); there is no separate async client.
Java conventions (read this first)
These are the things that most often trip people up with this SDK:
- Operations use Lombok builders. Every operation is built with `XxxOperation.builder()...
.build(), e.g. PaymentOperation.builder().destination(d).asset(a).amount(amt).build(). InvokeHostFunctionOperation instead exposes static factories (see references/operations.md`).
- There are three asset types — don't mix them up.
Asset(payments, offers, paths),
ChangeTrustAsset (the ChangeTrustOperation line, wraps an Asset or LiquidityPool), and TrustLineAsset (balances/trustline entries). See references/assets.md.
- Amounts and balances are `BigDecimal`.
new BigDecimal("10.5"), neverdouble/float. - `G...` and `M...` both work as a destination. Address strings accept plain ed25519
accounts and SEP-23 muxed accounts; use MuxedAccount to build/parse M... (see references/sep.md). Contracts have a muxed form too, W... (CAP-84, Protocol 30): a valid SAC transfer/mint destination, but never a signer or storage owner (see references/xdr_scval.md).
- Clients are `Closeable`.
Server.close(); wrapSorobanServer/ContractClientin
try-with-resources. SSEStream from .stream(...) must also be closed to stop it.
- SDK exceptions are unchecked. Everything extends
RuntimeException
(org.stellar.sdk.exception.SdkException), so the compiler will not force you to catch them — you still should. The common supertype for network/RPC errors is NetworkException.
- `KeyPair.getSecretSeed()` returns `char[]`, not
String, so it can be zeroed after use. - Android: works out of the box on API level 28+. For lower levels add the
- Example syntax. The SDK runs on Java 8+, but the snippets in this skill use some
Java 9–16 conveniences for brevity. On Java 8, substitute equivalents: List.of(...) → Arrays.asList(...), Map.of(...) → a populated LinkedHashMap, "x".repeat(n) → a literal, pattern-matching instanceof → a classic cast, and java.net.http → HttpURLConnection or any HTTP client.
Critical rules (do not violate)
- `BigDecimal` amounts, never `double`/`float`. Use
new BigDecimal("350.1234567"),
not 350.1234567. Lumens have 7 decimal places; binary floats lose precision.
- Prefer loading secret seeds at runtime (env / a secret manager) over embedding
them in source: KeyPair.fromSecretSeed(System.getenv("STELLAR_SECRET_KEY")).
- Always set a timeout with
.setTimeout(...)(or explicit time bounds). A
transaction without one can hang in the pending pool indefinitely.
- Use the correct network.
Network.TESTNETvsNetwork.PUBLIC. Signatures are
network-specific; a testnet-signed transaction is invalid on mainnet.
- `TransactionBuilder.build()` increments the source account's sequence number. If you
build but do not submit (or submission fails with tx_bad_seq), reload the account with server.loadAccount(...) before building again.
- For Soroban, prepare before signing.
sorobanServer.prepareTransaction(tx)(or
ContractClient.invoke(...) which simulates by default) fills in footprint, auth, and resource fees. Signing before this produces an invalid transaction.
- Convert contract args with `Scv.to*` and read results with
Scv.from*. Never pass
raw Java values to a contract.
- Restore archived state when simulation reports archived entries (see
references/soroban.md).
- Close clients. Call
server.close()forServer; use try-with-resources for
SorobanServer and ContractClient (both implement Closeable).
- Catch specific SDK exceptions (
BadRequestException,BadResponseException,
PrepareTransactionException, …), not a broad Exception. They all extend SdkException; network/HTTP errors additionally share the NetworkException supertype, but PrepareTransactionException and the contract-lifecycle exceptions extend SdkException directly. Network/RPC exceptions live in org.stellar.sdk.exception; ContractClient/AssembledTransaction errors live in org.stellar.sdk.contract.exception.
Minimal end-to-end examples
1. Create / load a keypair
2. Build, sign, and submit a payment
New testnet accounts can be funded by Friendbot: GET https://friendbot.stellar.org?addr=<G...>.
3. Query Horizon
4. Invoke a Soroban contract (read-only)
For contracts you call repeatedly, prefer generated typed bindings (see references/bindings.md). The hand-written form with ContractClient is:
For a state-changing call, pass source and signer, then signAndSubmit(...). See references/soroban.md.
Reference index
Load on demand:
references/quickstart.md— install → keypair → fund → payment → query → contract.references/transactions.md— transaction lifecycle, memos, preconditions, fee bump,
multisig, XDR round-trips, sequence-number pitfalls.
references/assets.md—AssetvsChangeTrustAssetvsTrustLineAsset, native vs
alphanum4/12, canonical form.
references/operations.md— catalog of every operation and its builder.references/horizon.md— Horizon client, request builders, pagination, streaming, errors.references/soroban.md— Soroban RPC client +ContractClient/AssembledTransaction.references/bindings.md— generate typed contract clients withstellar-contract-bindings.references/xdr_scval.md— SCVal conversion,Address, XDR encode/decode.references/sep.md— SEP support matrix and common flows (SEP-02/05/10/23/35/45/...).references/troubleshooting.md— exception hierarchy and common failures.
Full API docs (Javadoc): https://javadoc.io/doc/network.lightsail/stellar-sdk
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/java-stellar-sdk/SKILL.md
Popularity
- Repository stars
- 202
- Repository forks
- 161
- 7-day trend score
- 27
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lightsail-network/java-stellar-sdk/java-stellar-sdk)