diff --git a/src/components/layout/Navbar.jsx b/src/components/layout/Navbar.jsx index c74819f..f482409 100644 --- a/src/components/layout/Navbar.jsx +++ b/src/components/layout/Navbar.jsx @@ -1,8 +1,11 @@ -import { useAccount, useConnect, useDisconnect } from "wagmi"; +import { useAccount, useConnect, useContractRead, useDisconnect } from "wagmi"; import { dNFTfloor } from "../../utils/stats"; import { formatUSD } from "../../utils/currency"; import { addressSummary } from "../../utils/address"; +import dyadABI from "../../consts/abi/dNFTABI.json"; import Button from "../Button"; +import { useState } from "react"; +import { CONTRACT_DYAD } from "../../consts/contract"; export const NavBar = ({ tvl }) => { const { address } = useAccount(); @@ -10,11 +13,28 @@ export const NavBar = ({ tvl }) => { const { connect, connectors, error, isLoading, pendingConnector } = useConnect(); + const [balanceOf, setBalanceOf] = useState(0); + + const {} = useContractRead({ + addressOrName: CONTRACT_DYAD, + contractInterface: dyadABI, + functionName: "balanceOf", + args: [address], + onSuccess: (data) => { + console.log("balanceOf", data); + setBalanceOf(parseInt(data._hex) / 10 ** 18); + }, + onError: (e) => { + console.log("balanceOf", e); + }, + }); + return (