Authentication

JWT Authentication

Authentication Flow

The widget uses JWT (JSON Web Token) authentication to securely communicate with the orda API:

1

Initial request

When OrdaProvider mounts, it calls your getToken() function.

2

Server exchange

Your server route exchanges clientId + clientSecret for a JWT.

3

Token storage

JWT is stored in React state and used for all API requests.

4

Auto-refresh

SDK automatically refreshes the token 5 minutes before expiration.

5

Request queuing

Requests during refresh are queued and executed after completion.

Token Permissions

Your JWT should include the following permissions:

Permission
Description

quotes:read

Generate payment quotes

offramp:read

Off-ramp operations (crypto → fiat)

onramp:read

On-ramp operations (fiat → crypto)

transactions:read

View transaction status

recipients:read

List saved recipients

recipients:write

Create/update recipients

Security Best Practices

  1. Never expose clientSecret in browser code

    • Always generate JWT server-side

    • Use environment variables for secrets

    • Never commit secrets to version control

  2. Use HTTPS in production

    • Ensure your JWT endpoint uses HTTPS

    • Tokens sent over HTTP can be intercepted

  3. Implement rate limiting

    • Limit JWT generation requests per IP/user

    • Prevent abuse of your authentication endpoint

  4. Set appropriate token expiration

    • Default: 1 hour (expiresIn: 3600)

    • Balance security and user experience

    • SDK handles auto-refresh seamlessly

Example with Error Handling


Environment Variables

Required Variables

Variable
Description
Where to Get It

NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID

WalletConnect project ID

ORDA_CLIENT_ID

orda project ID (server-side)

orda Developer Portal

ORDA_CLIENT_SECRET

orda API secret (server-side)

orda Developer Portal

Optional Variables

Variable
Description
Default

NEXT_PUBLIC_ORDA_API_BASE_URL

orda API base URL

https://api.orda.network/v1

Example .env.local

Getting Your Credentials

1

WalletConnect Project ID

  1. Sign up or log in

  2. Create a new project

  3. Copy your Project ID

  4. Add your app domains to the allowlist

2

orda API Credentials

  1. Visit the orda Developer Portal

  2. Sign up for an account

  3. Create a new project

  4. Copy your Client ID and Client Secret

Last updated