Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.oneswap.cc/llms.txt

Use this file to discover all available pages before exploring further.

Wallet auth flow

The public SDK does not manage wallet connections for you, but it does expose OneSwap wallet-auth helpers:
  • client.walletAuth.requestChallenge(partyId)
  • client.walletAuth.verifyChallenge({ partyId, nonce, signature, publicKey })
Use your own wallet provider to:
  1. connect the wallet
  2. read the user’s Canton party ID
  3. sign the OneSwap challenge message
  4. pass the signature and public key back to OneSwap

Example browser flow

import { OneSwap } from '@oneswap/sdk'

const apiKey = 'os_live_...'
const partyId = 'alice::12205a8c...'

const authClient = new OneSwap({ apiKey })
const challenge = await authClient.walletAuth.requestChallenge(partyId)
const signature = await wallet.signMessage(challenge.message)

const verified = await authClient.walletAuth.verifyChallenge({
  partyId,
  nonce: challenge.nonce,
  signature,
  publicKey: wallet.publicKey,
})

const client = new OneSwap({
  apiKey,
  walletToken: verified.token,
})

const swap = await client.swaps.create({
  fromToken: 'Amulet',
  toToken: 'USDCx',
  amount: '100',
  walletAddress: partyId,
})
The returned depositAddress is the pool swap party, not the user’s own party. If the wallet supports Canton reason/reference metadata, pass through depositReference for faster fallback matching.

Using a token getter

If your app stores wallet auth in local state, pass walletToken as a function so the SDK always reads the latest token.
const client = new OneSwap({
  apiKey,
  walletToken: () => getStoredWalletToken() || undefined,
})

Notes

  • The wallet token is short-lived. Refresh it by repeating the challenge-signature flow.
  • If you pass walletAddress, it must match the authenticated wallet token.
  • Deposits must come from the same signed-in wallet party.
  • OneSwap does not custody user funds or forward deposits through your backend.