Back

Firebase

Firebase

Overview

Firebase is an app development platform built around non-relational technologies.

  1. Authentication Users.
  2. Firestore Database Documents.

Following the sample integration with Firebase.

1. Clone and configure the sample


_10
git clone https://github.com/openfort-xyz/samples
_10
cd firebase-wagmi-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>

2. Create a Policy and add a 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 tor .env.

NEXTAUTH_OPENFORT_PLAYER is the ID of a Player for your player.

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. Get your Firebase Config

First go to Firebase config: Console > Project settings > General and create an app for your project if you still don't have one.

image

Copy the FirebaseConfig and continue

image

Then go to Firebase-Admin config: Console > Project settings > Service accounts and generate a "New Private Key"

image

Update .env


_20
#firebase
_20
NEXT_PUBLIC_apiKey=
_20
NEXT_PUBLIC_authDomain=
_20
NEXT_PUBLIC_projectId=
_20
NEXT_PUBLIC_storageBucket=
_20
NEXT_PUBLIC_messagingSenderId=
_20
NEXT_PUBLIC_appId=
_20
_20
_20
#Firebase-admin
_20
type=
_20
project_id=
_20
private_key_id=
_20
private_key=
_20
client_email=
_20
client_id=
_20
auth_uri=
_20
token_uri=
_20
auth_provider_x509_cert_url=
_20
client_x509_cert_url=

4. Follow the server instructions on how to run

Install & Run:


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

Details

CategoryAuth
DocumentationLearn
Live demoExplore

Get started with Firebase and Openfort.