Stash Wallet SDK
Official JavaScript / TypeScript SDK for third-party websites. Sites communicate through the extension's injected window.stashwallet provider. The SDK holds no private keys and does not manage backend sessions, pricing, or application permissions.
Download and build from Git
Get the SDK source from [email protected]:rgbstashlabs/stash-wallet-sdk.git. Install Git, Node.js, and npm first, and configure an SSH key with access to GitHub.
Run these commands in the parent directory of your application project:
git clone [email protected]:rgbstashlabs/stash-wallet-sdk.git
cd stash-wallet-sdk
npm ci --include=dev
npm run buildnpm ci installs the dependencies required to build the source. A successful build generates ESM, CommonJS, TypeScript declarations, and a browser UMD bundle in dist/. The source repository does not include dist/, so build before using the SDK.
Use in a JavaScript / TypeScript project
Return to your application project root and run the following command. This assumes your application and stash-wallet-sdk/ share a parent directory; adjust the relative path otherwise:
npm install ../stash-wallet-sdkThis adds the local SDK directory as a project dependency. Continue to use import { StashWalletClient } from 'stash-wallet-sdk' in your code, as shown in the quick start below. CI and other development environments must also check out and build the SDK before installing the local dependency at the same relative path. Pin a verified Git tag or commit for reproducible use.
Use in a plain HTML page
Copy the generated dist/stash-wallet-sdk.umd.js into your site's static assets and host it yourself. The example assumes the file is deployed at /assets/stash-wallet-sdk.umd.js; this path is not a hosted CDN:
<script src="/assets/stash-wallet-sdk.umd.js"></script>
<script>
const { StashWalletClient } = window.StashWalletSDK;
</script>Quick start
Run in browser client code, not during SSR initialization:
import { StashWalletClient } from 'stash-wallet-sdk'
const client = await StashWalletClient.connect()
const { address } = await client.connect()
const { network } = await client.getNetwork()
const capabilities = await client.getCapabilities()
const accounts = await client.getAccounts()The two calls have different meanings:
- Static
StashWalletClient.connect()discovers the provider and creates a client; it does not establish user authorization. - Instance
client.connect()requests site access approved by the user inside the extension and returns{ address }.
Use getWalletSessionStatus() to query the session and disconnect() to revoke the current origin's authorization. Disconnecting a site does not lock the entire wallet.
Check runtime capabilities
const caps = await client.getCapabilities()
const { network } = await client.getNetwork()
if (!caps.canAuthSign || !caps.authNetworks.includes(network)) {
throw new Error('Identity signing is unavailable on this wallet/network')
}Documentation
- API reference: every client request method, parameters, results, and units.
- Auth login: V2 challenges, signed context, backend verification, and V1 compatibility.
- Provider and events: discovery, subscriptions, transports, and timeouts.
- Errors and compatibility: error handling, support limits, and security boundaries.