Provisioning server sessions
Wallets created through Privy can either be used directly from a user’s device or from a server. To allow wallets created on user devices to be used from the server, follow the guide below.
To provision server-side access for a user’s wallets, use the delegateWallet
method from the useHeadlessDelegatedActions
hook:
Usage
Parameters
The delegateWallet
method accepts a params
object with the following fields:
Address of the embedded wallet to delegate.
Chain type of the embedded wallet to delegate.
In addition to a full whitelabel experience, Privy also offers a default UI component to prompt users to delegate their wallet for server sessions. Learn more
To provision server-side access for a user’s wallets, use the delegateWallet
method from the useHeadlessDelegatedActions
hook:
Usage
Parameters
The delegateWallet
method accepts a params
object with the following fields:
Address of the embedded wallet to delegate.
Chain type of the embedded wallet to delegate.
In addition to a full whitelabel experience, Privy also offers a default UI component to prompt users to delegate their wallet for server sessions. Learn more
To provision server-side access for a user’s wallets, use the delegateWallet
method from the useHeadlessDelegatedActions
hook:
Usage
Parameters
The delegateWallet
method accepts a params
object with the following fields:
Address of the embedded wallet to delegate.
Chain type of the embedded wallet to delegate.
Using wallets
Getting wallets
From your server, you can query Privy to determine what wallets have been provisioned server sessions by a given user to allow your app to take actions on their behalf.
Use the Privy client’s getUser
method to get the user object for your user. As a parameter to this method, pass the user’s DID as a string
:
Then, to get a list of the user’s server session provisioned wallets, first find all of the user’s embedded wallets from the user’s linked accounts. Simply filter the user.linkedAccounts
array for wallet entries with walletClientType: 'privy'
:
Then, filter the array of embedded wallets for entries where the delegated
flag is set to true:
This constitutes the user’s server session provisioned wallets. Server session provisioned wallets will always have the delegated
flag set to true
.
For wallets included in this array, your app may make requests to Privy to execute actions on Solana or EVM networks on behalf of the user.
Use the Privy client’s getUser
method to get the user object for your user. As a parameter to this method, pass the user’s DID as a string
:
Then, to get a list of the user’s server session provisioned wallets, first find all of the user’s embedded wallets from the user’s linked accounts. Simply filter the user.linkedAccounts
array for wallet entries with walletClientType: 'privy'
:
Then, filter the array of embedded wallets for entries where the delegated
flag is set to true:
This constitutes the user’s server session provisioned wallets. Server session provisioned wallets will always have the delegated
flag set to true
.
For wallets included in this array, your app may make requests to Privy to execute actions on Solana or EVM networks on behalf of the user.
Make a GET
request to:
Replace <did>
with your desired Privy DID. It should have the format did:privy:XXXXXX
.
Below is a sample cURL command for this request:
Then, to get a list of the user’s delegated wallets, inspect the linked_accounts
field of the response body for all entries with the fields type: 'wallet'
and delegated: true
.
Using server sessions
Wallets provisioned for server sessions can be used to transact and sign messages on behalf of a user from your server.
EVM
Send a transaction or sign a message on behalf of a user from our NodeJS SDK or our REST API. Learn more about sending transactions or signing messages.
Solana
Send a transaction or sign a message on behalf of a user from our NodeJS SDK or our REST API. Learn more about sending transactions or signing messages.
Revoking server sessions
Once a user has provisioned a server session, they may also revoke consent to prevent your app from taking any further wallet actions on their behalf.
To revoke a user’s server session automatically, without a revocation screen, use the revokeWallets
method from the useHeadlessDelegatedActions
hook:
When invoked, the revokeWallets
method will revoke all of the user’s server session provisioned wallets.
Once a user confirms revocation, your app will no longer be able to take actions on behalf of the user with their wallet unless the user provisions a server session.
If a user has provisioned multiple server sessions, they will all be revoked.
As an example, you might have a button within your app to allow users to revoke server session provisioned wallets like so:
To revoke a user’s server session automatically, without a revocation screen, use the revokeWallets
method from the useHeadlessDelegatedActions
hook:
When invoked, the revokeWallets
method will revoke all of the user’s server session provisioned wallets.
Once a user confirms revocation, your app will no longer be able to take actions on behalf of the user with their wallet unless the user provisions a server session.
If a user has provisioned multiple server sessions, they will all be revoked.
As an example, you might have a button within your app to allow users to revoke server session provisioned wallets like so:
To revoke a user’s server session provisioned wallets automatically, without a revocation screen, use the revokeWallets
method from the useHeadlessDelegatedActions
hook:
When invoked, the revokeWallets
method will revoke all of the user’s server session provisioned wallets.
Once a user confirms revocation, your app will no longer be able to take actions on behalf of the user with their wallet unless the user provisions a server session.
If a user has provisioned multiple server sessions, they will all be revoked.
As an example, you might have a button within your app to allow users to revoke server session provisioned wallets like so: