Backend example on GitHub
Follow the TypeScript application: set up test accounts, deposit XLM, send private transfers, and withdraw.
Start with the example
Clone the repository and follow its README to run the application. This guide focuses on the Arcane integration; the example’s framework and storage are application choices.845068536382695. Keep the matching settings from its .env.example file. See Set up the SDK to register your own application.
In the app, select Setup accounts, make a small Deposit, and check the private balance. Use Start and Stop to try private transfers between the test accounts, then Withdraw.
Connect the SDK
Account client setup creates a client for each server-controlled account. It connects:- The account address, message signer, and transaction signer.
- Network and application configuration.
- The SDK runtime asset and transaction configuration.
- An account-scoped state adapter.
- KYT and recipient-resolution configuration.
resolveStellarPrivacyClientConfig and constructs the client with createStellarPrivacyClientFromResolvedConfig. Its transaction-engine setup also supports the example’s Relay preparation flow. Reuse the complete setup when following the example.
You can integrate the SDK into another Node.js application without adopting the example’s framework.
Keep state on the server
The example uses@arcanetech/privacy-sdk-state-memory for SDK state and adds application-managed persistence. The basic adapter starts with:
Set up private accounts
The example’s account setup derives test accounts, funds them on Stellar testnet, and registers their private addresses. The registration flow signs an SDK-generated message on the server, derives and saves the private address, and callsregisterPrivateAddress. It then checks registration with checkRegistrationStatus.
Your application can supply its own signer. Keep message signing and transaction signing tied to the same account. This account registration is separate from registering your application.
Deposit funds
The excerpts below follow PrivacyJobRunner. Here,client belongs to the selected account; publicKey, privateAddress, and env come from account setup and configuration.
Refresh pool state, then prepare the deposit:
Send a private transfer
The example resolves the recipient’s private address and callsclient.transfer:
submitRelayAndFinalize. Keep the submission and state updates together; preparing a transfer is not sufficient to update either balance.
Withdraw funds
The example withdraws to the selected account’s public address:execute() call for this private-sender withdrawal.