Back

Web3Auth

Web3Auth

Overview

This sample uses Web3Auth as the key management and authentication solution.

Following the sample Web3Auth integration with Openfort:

1. Clone and configure the sample


_10
git clone https://github.com/openfort-xyz/samples
_10
cd web3auth-nextjs

Copy the .env.local.example file into a file named .env.local in the folder of the server you want to use. For example:


_10
cp .env.local.example .env.local

You will need an Openfort account in order to run the demo. Once you set up your account, go to the Openfort developer dashboard to find your API keys.


_10
NEXT_PUBLIC_OPENFORT_PUBLIC_KEY=<replace-with-your-publishable-key>
_10
NEXTAUTH_OPENFORT_SECRET_KEY=<replace-with-your-secret-key>

The other environment variables are configurable:

NEXT_PUBLIC_GOOGLE_ID is the client_id from Google. You can get it from https://console.cloud.google.com/apis/credentials

NEXT_PUBLIC_WEB3_AUTH_ID is the client_id from Web3Auth. You can get it from https://dashboard.web3auth.io

You can follow the instructions on how to set up the Web3Auth sample in the Web3Auth Google documentation.

2. Create a Policy and Contract

You can create Policies and add Contracts in the Dashboard or with the API. This sample requires a Policy and a Contract to run. Once you've created them, and add its ID to your .env.

NEXTAUTH_OPENFORT_CONTRACT is the ID of a Contract for your contract. A contract has a chainId. If you need a test contract address, use 0x38090d1636069c0ff1Af6bc1737Fb996B7f63AC0 (NFT contract deployed in 80001 Mumbai).

NEXTAUTH_OPENFORT_POLICY is the ID of a Policy for your contract. A policy has a contract and chainId. For this demo to work, the policy must have both the contract and the register sessions as rules.

3. Follow the server instructions on how to run

Install & Run:


_10
npm install
_10
npm run dev
_10
# or
_10
yarn
_10
yarn dev

Other available integrations with Web3Auth

Web3Auth also offers an MPC solution, also available as a sample MPC integration.

Details

DocumentationLearn
Live demoExplore

Get started with Web3Auth and Openfort.