A common setup for Privy apps is to configure wallets such that both users and apps themselves can execute transactions from user wallets. This serves a variety of use cases:
You can accomplish these use cases via session signers, which enable user to grant specific permissions to your app to transact on their behalf. Follow the guide below to learn how to integrate session signers for your use case.
Prior to following this guide, follow the quickstart for Privy’s React SDK or React Native SDK to get your app instrumented with Privy’s basic functionality.
If you plan to use this setup as part of a Telegram trading bot, check out the guide to integrate Telegram seamless login with the React SDK for a smoother user experience when signing into Telegram mini-apps.
To allow your app to be send transactions from user wallets, you must first create an app authorization key. Your app’s server will sign API requests with this key to authorize sending transactions from user wallets.
Create an authorization key locally on your machine like so:
Retrieve the public key from the public.pem
file and the private key from the private.pem
file in your working directory.
Make sure to save both files securely. Privy does not store your private key and cannot help you recover it.
Next, register the public key you created with Privy so that Privy can appropriately verify signed requests from your app.
To do so, visit the Authorization keys page of the Privy Dashboard and click the New key button in the top right. Then, click the Register key quorum instead option.
In the modal that pops up, enter the public key you generated in step 1 in the Public keys field. Set the Authorization threshold to 1, to allow that single key to sign on behalf of the key quorum, and set the Quorum name to a human readable name of your choice.
Save the id
of the key quorum that is created. You will need this value later.
This creates a 1-of-1 key quorum that can be granted permission to execute actions from a user’s wallet.
You can also register the public key with Privy programmatically via the REST API.
Next, configure your Privy app to automatically create embedded wallets when users login.
This ensures that all users have an embedded wallet, regardless of whether they login via a web app, a Telegram mini app, or a native mobile app.
In your PrivyProvider
component, set the config.embeddedWallets.ethereum.createOnLogin
property to 'all'
to automatically create embedded wallets for users, regardless of what login method they use.
In your PrivyProvider
component, set the config.embeddedWallets.ethereum.createOnLogin
property to 'all'
to automatically create embedded wallets for users, regardless of what login method they use.
In your PrivyProvider
component, set the config.embeddedWallets.ethereum.createOnLogin
property to 'all'
to automatically create embedded wallets for users, regardless of what login method they use.
If you’d like your signer to only have specific permissions on users’ wallets, create a policy for your signer based on the transaction it needs to execute. For example, you might create a policy that only allows transacting under a certain amount with a specific contract, in order to execute a limit order when a user is offline. You can also create multiple policies to allow your signer to execute a set of actions.
Once you’ve created your desired policy for the signer, make sure to save the policy ID. You will need this when adding your signer to users’ wallets.
Once a user logs in, an embedded wallet will automatically be created for them.
Once a user has an embedded wallet, add the key quorum you created in step 3 as a session signer to the user’s wallet. This allows your app to sign transaction requests from the user’s wallet via your app’s authorization key.
Once a user logs in, you can use the addSessionSigners
method of useSessionSigners
hook to add your app’s authorization key as a session signer on the wallet.
Add a session signer to a user's wallet immediately after they login.
If you’d like to immediately add your session signer to a user’s wallet when they login, use the onComplete
callback of the useLogin
hook:
All together, you can add a session signer after a user logs in like so:
Add a session signer for limit orders.
If your app offers limit orders to users, we recommend the following flow for using session signers to execute limit orders.
Create your limit order policy
Create a policy that allows your session signer to execute the limit order from the user’s wallet.
Add your session signer
Add your session signer to the user’s wallet via the addSessionSigner
method, using the policy from step 1.
Execute the limit order
When the conditions to execute the limit order are met, see step 6 of this guide to learn how to send transactions with your session signer.
Once a user logs in, you can use the addSessionSigners
method of useSessionSigners
hook to add your app’s authorization key as a session signer on the wallet.
Add a session signer to a user's wallet immediately after they login.
If you’d like to immediately add your session signer to a user’s wallet when they login, use the onComplete
callback of the useLogin
hook:
All together, you can add a session signer after a user logs in like so:
Add a session signer for limit orders.
If your app offers limit orders to users, we recommend the following flow for using session signers to execute limit orders.
Create your limit order policy
Create a policy that allows your session signer to execute the limit order from the user’s wallet.
Add your session signer
Add your session signer to the user’s wallet via the addSessionSigner
method, using the policy from step 1.
Execute the limit order
When the conditions to execute the limit order are met, see step 6 of this guide to learn how to send transactions with your session signer.
Once a user logs in, you can use the addSessionSigners
method of useSessionSigners
hook to add your app’s authorization key as a session signer on the wallet.
Add a session signer for limit orders.
If your app offers limit orders to users, when a user places an order, we recommend:
addSessionSigner
method, using the policy from step 1.That’s it! Now, both users and your app can send transactions from a user’s wallet.
Users can send transactions from your app’s frontend by taking actions in a web app (via Privy’s React SDK), a mobile app (via Privy’s React Native SDK), or a Telegram mini-app (via Privy’s React SDK).
Follow the guides below to learn how to send transactions from these environments.
Send Ethereum transactions from a web app or a Telegram mini-app using Privy’s React SDK.
Send Ethereum transactions from a mobile app or a Telegram mini-app using Privy’s React Native SDK.
Send Solana transactions from a web app or a Telegram mini-app using Privy’s React SDK.
Send Solana transactions from a mobile app or a Telegram mini-app using Privy’s React Native SDK.
Your app can also now initiate transactions from users’ wallets via Privy’s NodeJS SDK or REST API. This allows your app to send transactions from users’ wallets even when the user is offline, allowing for various use cases:
Follow the guides below to send transactions from your app’s server using your app’s authorization key.
Using Privy’s REST API directly is an advanced integration. If your app uses a JavaScript or TypeScript backend, we strongly recommend using Privy’s NodeJS SDK.
To start, initialize your PrivyClient
with the private key of the authorization key you created in step 1. Pass this value into the walletApi.authorizationPrivateKey
field of the third positional parameter to the client’s constructor.
Next, follow the guides to send transactions on Ethereum and Solana with the NodeJS SDK.
To start, initialize your PrivyClient
with the private key of the authorization key you created in step 1. Pass this value into the walletApi.authorizationPrivateKey
field of the third positional parameter to the client’s constructor.
Next, follow the guides to send transactions on Ethereum and Solana with the NodeJS SDK.
Since your app is a session signer on the user’s wallet, your app must sign transaction requests to Privy’s API with the private key of the authorization key you generated in step 1. Your app must then include this signature in the privy-authorization-signature
header of the request.
Follow this guide to learn how to sign requests to Privy’s API with your app’s authorization key.
Once you’ve learned and implemented how to sign requests, you can now follow the guides to send transactions on Ethereum and Solana with the NodeJS SDK.
Building a Telegram trading bot? Check out the Telegram trading bot recipe to learn how to have your app initiate transactions on behalf of users with a trading bot.