Giter VIP home page Giter VIP logo

biconomy-example's Introduction

Privy x Biconomy Starter

Live Demo

https://biconomy-example.privy.io/

Intro

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!

Setup

  1. Fork this repository, clone it, and open it in your terminal.
git clone https://github.com/<your-github-handle>/
  1. Install the necessary dependencies (including the Privy SDK and Biconomy's SDKs) with npm.
npm i
  1. 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>

Building locally

In your project directory, run npm run dev. You can now visit http://localhost:3000 to see your app and login with Privy!

Learn more

Check out the following files to learn more about the integration!

pages/_app.tsx

This demonstrates how to wrap your React app with the PrivyProvider, and how to configure Privy's login methods, embedded wallets, etc.

hooks/BiconomyContext.tsx

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.

pages/index.tsx

This demonstrates how to use Privy's login method to authenticate your users and create an embedded wallet for them.

pages/dashboard.tsx

This demonstrates how to use a Biconomy smart account's buildUserOp and sendUserOp methods to mint an ERC-721 NFT gaslessly.

biconomy-example's People

Contributors

ankushswar1 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.