Frontend example on GitHub
Follow the React and TypeScript application: connect a wallet, deposit XLM, send private transfers, and withdraw.
Run the example
Use Node.js 20 or later and a browser with Freighter installed. Select Stellar testnet in the wallet and fund the account with test XLM.3722412212248783. Keep the matching settings from its environment file. See Set up the SDK to register your own application.
In the app, connect Freighter, select Create private address (or Restore), and make a small Deposit. Then try Transfer and Withdraw.
Connect the SDK
Client setup connects five inputs:- Network and application configuration from
.env. - The connected wallet’s address and signing functions.
- The SDK state adapter.
- The browser runtime asset.
- KYT and transaction-submission configuration.
resolveStellarPrivacyClientConfig, checks the result, and creates the client with createStellarPrivacyClientFromResolvedConfig. It also loads the XLM asset configuration with upsertAssets.
Use bootstrapPrivacyClient() from the example to initialise that setup. Later operations obtain the same client through getPrivacyClient(). These are application helpers, not SDK exports.
Connect state to the UI
The example uses@arcanetech/privacy-sdk-state-redux. The core wiring in store.ts is:
privacySdkState.adapter as the client’s state. The full example also initialises the state and restores the connected account’s saved snapshot.
If your frontend does not use Redux, use @arcanetech/privacy-sdk-state-memory and update your UI after operations. In either case, saving and restoring account data is an application responsibility.
Create or restore a private address
Private-address setup asks the wallet to sign an SDK-generated message, derives the private address, saves the account data, and checks its registration. The example exposescreateOrRestorePrivateAddress(owner) for this flow. Restore an existing address rather than treating a fresh browser store as a new account.
This user-account step is separate from the test application’s registration.
Deposit funds
operations.ts exposesrunDeposit, runTransfer, and runWithdraw. These helpers include pool synchronisation, preparation checks, and submission.
Call them from your UI after account setup:
runDeposit, the SDK prepares the operation with:
Transfer and withdraw
Use the same application helpers for the next operations:stpl1 address or a Stellar G address. The example resolves whether the recipient is registered and selects the corresponding transfer flow.
Transfers and withdrawals in this example keep the sender private and use Relay. Keep the submission helper connected; calling execute() directly is not a substitute for Relay.