User details not showing in real-time database or firestore moralis firebase

After successfully authenticating user, I still wasn’t able to get user wallet informations (wallet address, transaction history, balance) to my firestore or realtime database, but the user uid/harsh token is authenticated in firebase authentication. Please what am I missing?

Hi, these are not saved by default, you will have to listen to which address is connected and fetch the data yourself, then use something like firebase sdk to add the data to the user

Thanks for the reply, please how can I do this with firestore?

We dont have an example for this, you can check the firestore documentation to learn how to add data
https://firebase.google.com/docs/firestore/quickstart

import { Button, Text, Flex, Center, useColorModeValue, Image, Box, Tabs, TabList, Tab, TabPanels, TabPanel, Alert, AlertIcon, Link, styled, AccordionButton } from "@chakra-ui/react"

import Head from "next/head"

import { useMoralis, useWeb3Contract } from "react-moralis"

import Balance from "../components/Balance"

import Transactions from "../components/Transactions"

import Header from "../components/Header"

import Profile from "../components/Profile"

import moralisV1 from 'moralis-v1'

import { useEffect, useState } from "react"

import { Modal, ModalOverlay, ModalContent, ModalHeader, ModalFooter, ModalBody, ModalCloseButton } from '@chakra-ui/react'

import { useDisclosure } from '@chakra-ui/react'

import { MoralisProvider } from "react-moralis";

import { initializeApp } from "firebase/app";

import { getAuth } from '@firebase/auth';

import {getDatabase} from 'firebase/database';

import { getFirestore, doc, setDoc } from "firebase-admin/firestore"

import { getMoralisAuth } from '@moralisweb3/client-firebase-auth-utils';

import { signInWithMoralis } from '@moralisweb3/client-firebase-evm-auth';

import { getFunctions } from "firebase/functions"

import WalletConnectProvider from "@walletconnect/web3-provider";

import { Web3Provider } from '@ethersproject/providers';

const firebaseConfig = {

  apiKey: "AIzaSyBb5Pt9inGrPrVXp-sEtkCt3JX-Dn8i1BY",

  authDomain: "crypto-c63aa.firebaseapp.com",

  projectId: "crypto-c63aa",

  storageBucket: "crypto-c63aa.appspot.com",

  messagingSenderId: "816656453821",

  appId: "1:816656453821:web:44e0bb46ab1c494875e7d4",

  measurementId: "G-HRE2LN8J9N"

};

const app = initializeApp(firebaseConfig);

const database = getDatabase();

// const db = getFirestore();

//const moralisAuth = getMoralisAuth(app);

const auth = getAuth(app);

const functions = getFunctions(app);

// const Container = styled.div`

//   display: flex;

//   justify-content: center;

//   align-items: center;

//   height: 100vh;

// `;

// const Button = styled.button`

//   min-width: 100px;

//   padding: 16px 32px;

//   border-radius: 4px;

//   border: none;

//   background: #141414;

//   color: #fff;

//   font-size: 24px;

//   cursor: pointer;

// `;

function Home() {

  const [user, setUser]= useState(null);

  //const { EvmChain } = require("@moralisweb3/common-evm-utils");

  // const walletAddress = user;

  // const userRef = doc(db, "users", user.id);

  // setDoc(userRef, { walletAddress}, {merge:true}).then(() => {

  //   console.log("Wallet address stored")

  // })

  // .catch((error) => {

  //   console.error("error storig wallet", error)

  // });

  const { getFirestore, Timestamp, FieldValue } = require('firebase-admin/firestore');

  const docRef = db.collection('users').doc('walletAddress');

  async function address(){

  await docRef.set({

    walletAddress: user

  });

}

console.log()

i recommend checking this example
https://www.geeksforgeeks.org/how-to-use-firestore-database-in-reactjs/


i followed everything on that link but i keep getting this error

import { firebase } from "firebase";

const firebaseConfig = {

    apiKey: "AIzaSyBb5Pt9inGrPrVXp-sEtkCt3JX-Dn8i1BY",

    authDomain: "crypto-c63aa.firebaseapp.com",

    projectId: "-c63aa",

    storageBucket: "crypto-.com",

    messagingSenderId: "",

    appId: "1:816656453821:web:",

    measurementId: "G-HRE2LN8J9N"

  };

 

  const firebaseApp = firebase.initializeApp(firebaseConfig);

  const db = firebase.firestore();

  export default db;
import db from "../firebase";

//import firebase from "firebase";

// import { getAuth } from '@firebase/auth';

// import {getDatabase} from 'firebase/database';

import { getMoralisAuth } from '@moralisweb3/client-firebase-auth-utils';

import { signInWithMoralis } from '@moralisweb3/client-firebase-evm-auth';

import { getFunctions } from "firebase/functions"

import WalletConnectProvider from "@walletconnect/web3-provider";

import { Web3Provider } from '@ethersproject/providers';

// const database = getDatabase();

//const moralisAuth = getMoralisAuth(app);

// const auth = getAuth(app);

// const functions = getFunctions(app);

// const Container = styled.div`

//   display: flex;

//   justify-content: center;

//   align-items: center;

//   height: 100vh;

// `;

// const Button = styled.button`

//   min-width: 100px;

//   padding: 16px 32px;

//   border-radius: 4px;

//   border: none;

//   background: #141414;

//   color: #fff;

//   font-size: 24px;

//   cursor: pointer;

// `;

function Home() {

  const [user, setUser]= useState(null);

  //const { EvmChain } = require("@moralisweb3/common-evm-utils");

  // const walletAddress = user;

  // const userRef = doc(db, "users", user.id);

  // setDoc(userRef, { walletAddress}, {merge:true}).then(() => {

  //   console.log("Wallet address stored")

  // })

  // .catch((error) => {

  //   console.error("error storig wallet", error)

  // });

  const wallet = (e) => {

    e.preventDefault();

    db.collection("walletAddress").add({

        address: displayName,

    });

    console.log(wallet);

  }

index.js