Learn how to implement email logins and sponsored transactions with Privy & Pimlico.
View the completed code for this tutorial.
You are reading this tutorial because you probably want to do one or both of these things:
Here is how Privy describes both of these things:
Embedded wallets are self-custodial wallets provisioned by Privy itself for a wallet experience that is directly embedded in your application. Embedded wallets do not require a separate wallet client, like a browser extension or a mobile app, and can be accessed directly from your product. These are primarily designed for users of your app who may not already have an external wallet, or don’t want to connect their external wallet.
Smart wallets are programmable, onchain accounts that incorporate the features of account abstraction. With just a few lines of code, you can create smart wallets for your users to sponsor gas payments, send batched transactions, and more.
We will be implementing both using Privy + Pimlico.
There are a few steps you have to complete before you can start the tutorial.
.env
file and add your App ID:Story Aeneid Testnet
1315
https://aeneid.storyrpc.io
This is for testing. In a real scenario, you would have to set up proper sponsorship policies and billing info on Pimlico to automatically sponsor the transactions on behalf of your app. We don’t have to do this on testnet.
You can read Privy’s tutorial here that describes setting up Embedded Wallets, which is a fancy way of saying email login for your users. In the below example, we simply create an embedded wallet for every user, but you may want more customization by reading their tutorial.
You must wrap any component that will be using embedded/smart wallets with the PrivyProvider
and SmartWalletsProvider
. In a providers.tsx
(or whatever you want to call it) file, add the following code:
Then you can simply add it to yourlayout.tsx
like so:
You can add email login to your app like so:
We can use the generated smart wallet to sign messages:
We can also use the generated smart wallet to sponsor transactions for our users:
We can also use the generated smart wallet to send transactions from the 🛠️ TypeScript SDK. Some of the functions have an option to return the encodedTxData
, which we can use to pass into Privy’s smart wallet. You can see which functions support this in the SDK Reference.
View the completed code for this tutorial.
Explore more tutorials in our documentation
Learn how to implement email logins and sponsored transactions with Privy & Pimlico.
View the completed code for this tutorial.
You are reading this tutorial because you probably want to do one or both of these things:
Here is how Privy describes both of these things:
Embedded wallets are self-custodial wallets provisioned by Privy itself for a wallet experience that is directly embedded in your application. Embedded wallets do not require a separate wallet client, like a browser extension or a mobile app, and can be accessed directly from your product. These are primarily designed for users of your app who may not already have an external wallet, or don’t want to connect their external wallet.
Smart wallets are programmable, onchain accounts that incorporate the features of account abstraction. With just a few lines of code, you can create smart wallets for your users to sponsor gas payments, send batched transactions, and more.
We will be implementing both using Privy + Pimlico.
There are a few steps you have to complete before you can start the tutorial.
.env
file and add your App ID:Story Aeneid Testnet
1315
https://aeneid.storyrpc.io
This is for testing. In a real scenario, you would have to set up proper sponsorship policies and billing info on Pimlico to automatically sponsor the transactions on behalf of your app. We don’t have to do this on testnet.
You can read Privy’s tutorial here that describes setting up Embedded Wallets, which is a fancy way of saying email login for your users. In the below example, we simply create an embedded wallet for every user, but you may want more customization by reading their tutorial.
You must wrap any component that will be using embedded/smart wallets with the PrivyProvider
and SmartWalletsProvider
. In a providers.tsx
(or whatever you want to call it) file, add the following code:
Then you can simply add it to yourlayout.tsx
like so:
You can add email login to your app like so:
We can use the generated smart wallet to sign messages:
We can also use the generated smart wallet to sponsor transactions for our users:
We can also use the generated smart wallet to send transactions from the 🛠️ TypeScript SDK. Some of the functions have an option to return the encodedTxData
, which we can use to pass into Privy’s smart wallet. You can see which functions support this in the SDK Reference.
View the completed code for this tutorial.
Explore more tutorials in our documentation