Appearance
Using the SDK and REST API
You can use server wallets via Privy's NodeJS Server SDK or by making requests to Privy's REST API directly. Follow the instructions below to configure your desired integration.
Using the SDK
If your server is a NodeJS environment, you can integrate the @privy-io/server-auth
library to use server wallets.
To use @privy-io/server-auth
, first install the library:
sh
npm install @privy-io/server-auth@latest
Then, import the PrivyClient
class and create an instance of it. As parameters to the PrivyClient
's constructor, pass your Privy app ID and app secret as string
s.
tsx
import { PrivyClient } from '@privy-io/server-auth';
...
const privy = new PrivyClient('insert-your-app-id', 'insert-your-app-secret', {
walletApi: {
authorizationPrivateKey: 'insert-your-authorization-private-key-from-the-dashboard'
}
});
If you have also enabled an authorization key for your wallets in the Dashboard, pass the key to the constructor as illustrated above.
Using the REST API
You can also request Privy's REST API directly to use server wallets. When requesting the REST API directly, you must set certain headers on your requests.
Authorization
Include a basic auth Authorization
header with your Privy app ID as the username and your app secret as the password. The header is the base64-encoding of <privy-app-id>:<privy-app-secret>
.
This header is required on all requests.
privy-app-id
Include a privy-app-id
header with your Privy app ID.
This header is required on all requests.
privy-authorization-signature
If your app has registered authorization keys, when creating, modifying, or using wallets, you must sign your requests with your authorization key.
Follow the authorization signatures guide to correctly sign your requests to these endpoints with your authorization key. Include the computed authorization signature as a privy-authorization-signature
header on requests.
Authorization signatures are only required on POST
requests to the following endpoints:
/api/v1/wallets
/api/v1/wallets/<wallet_id>/rpc
If your app does not have a authorization key enabled, authorization signatures are not required.