Skip to content

Commit

Permalink
fixup! tzkt: add hook to get the xtz balance
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilou97 committed Mar 28, 2024
1 parent d606172 commit 7624e35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/tzktHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { TZKT_API_URL } from "../context/config";
export const useTzktBalance = (address: string | null) => {
const [balance, setBalance] = useState(0);
useEffect(() => {
if (address == null) return;
if (!address) return;
(async () => {
const response = await fetch(
`${TZKT_API_URL}/v1/accounts/${address}/balance`
);

if (response.status == 200) {
if (response.status === 200) {
const json: number = await response.json();
setBalance(json / 1_000_000); // Divided by the XTZ decimal
}
Expand Down

0 comments on commit 7624e35

Please sign in to comment.