Created
April 2, 2024 04:25
-
-
Save jsbeaudry/d43feff0967239b9ccd9e60337c69bcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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