Skip to content

Instantly share code, notes, and snippets.

@jsbeaudry
Created April 2, 2024 04:25
Show Gist options
  • Save jsbeaudry/d43feff0967239b9ccd9e60337c69bcf to your computer and use it in GitHub Desktop.
Save jsbeaudry/d43feff0967239b9ccd9e60337c69bcf to your computer and use it in GitHub Desktop.
import { useEffect, useState } from "react";
import Haiex from "haiex-sdk";
const GELATO_KEY = "";
const MAGIC_KEY = "";
const INFURA_KEY = "";
let haiex;
export default function App() {
const [user, setUser] = useState(null);
useEffect(() => {
haiex = new Haiex(GELATO_KEY, MAGIC_KEY, INFURA_KEY);
initiate();
}, []);
const initiate = async () => {
try {
const isLogged = await haiex.isLoggedIn();
if (isLogged) {
// await haiex.logOutUser();
const usr = await haiex.getUser();
setUser(usr);
const tokens = haiex.tokens;
console.log(tokens);
const balanceStables = await haiex.balanceStables();
console.log(balanceStables);
} else {
const connected = await haiex.connect("[email protected]");
console.log(connected);
}
} catch (err) {
console.log(err);
}
};
return <>User Wallet address: {user?.publicAddress}</>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment