https://biconomy-example.privy.io/
This is a template for integrating Privy and Biconomy into a NextJS project. Check out the deployed app here!
In this demo app, a user can login with their email, Google account, Discord account, Twitter account, or Apple account, and get a Privy embedded wallet. Once the user has logged in and created an embedded wallet, Biconomy will create a smart wallet for the user behind the scenes, which can then be used to incorporate gas sponsorship, batched transactions, and more into your app.
You can test this by logging into the app and attempting to mint an NFT with your smart wallet; it should cost you no gas!
- Fork this repository, clone it, and open it in your terminal.
git clone https://github.com/<your-github-handle>/
- Install the necessary dependencies (including the Privy SDK and Biconomy's SDKs) with
npm
.
npm i
- Initialize your environment variables by copying the
.env.example
file to an.env.local
file. Then, in.env.local
, paste:
- your Privy App ID from the Privy console
- an Infura API Key from the Infura dashboard. You can create an Infura account for free.
- your Biconomy Bundler URL from the Biconomy Dashboard. Make sure this corresponds to Polygon Mumbai.
- your Biconomy Paymaster URL from the Biconomy Dashboard. Make sure this corresponds to Polygon Mumbai.
# In your terminal, create .env.local from .env.example
cp .env.example .env.local
# Add your environment variables to .env.local
NEXT_PUBLIC_PRIVY_APP_ID=<your-privy-app-id>
NEXT_PUBLIC_INFURA_API_KEY=<your-infura-api-key>
NEXT_PUBLIC_BICONOMY_BUNDLER_URL=<your-biconomy-bundler-url-for-mumbai>
NEXT_PUBLIC_BICONOMY_PAYMASTER_URL=<your-biconomy-paymaster-url-for-mumbai>
In your project directory, run npm run dev
. You can now visit http://localhost:3000 to see your app and login with Privy!
Check out the following files to learn more about the integration!
This demonstrates how to wrap your React app with the PrivyProvider
, and how to configure Privy's login methods, embedded wallets, etc.
This demonstrates how to initialize a Biconomy smart account from a Privy embedded wallet. In this example app, we store the user's Biconomy smart account in a React context to allow us to easily access it from other pages/components.
This demonstrates how to use Privy's login
method to authenticate your users and create an embedded wallet for them.
This demonstrates how to use a Biconomy smart account's buildUserOp
and sendUserOp
methods to mint an ERC-721 NFT gaslessly.