I'm trying right now to integrate the Wax Cloud Wallet into my React/NextJS App.
For that, I'm using waxjs and the documentation here.
Right now, the User can log in to his account and the app receives the account name and two public keys. But I have no Idea how I then use that information to check which kind of NFTs are in the wallet, or if there are specific ones.
Is that with waxjs even possible, or do I have to use a different one?
Here is the code:
import React, { useEffect, useState } from 'react'
import * as waxjs from '@waxio/waxjs/dist'
const Wallet = () => {
const [userAccount, setUserAccount] = useState('No Wallet Linked')
const [pubKeys, setPubKeys] = useState('No Public Keys')
var wax
useEffect(() => {
wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
})
console.log('Started Wax:', wax)
}, [])
async function login() {
try {
const user = await wax.login()
const publicKeys = wax.pubKeys
console.log(pubKeys)
console.log(wax)
setUserAccount(user)
setPubKeys(publicKeys)
} catch (error) {
console.log('User failed to login: ', error)
}
}
return (
<div className="flex flex-col gap-10 text-center">
<h1 className="text-3xl font-bold">Wallet</h1>
<button
onClick={() => login()}
className="bg-orange text-black text-3xl px-4 py-2"
>
Login
</button>
<h4 className="font-semibold">{userAccount}</h4>
<h5>{pubKeys}</h5>
</div>
)
}
export default Wallet
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
I believe you want to use is this: https://wax.api.atomicassets.io/docs/ You can get to this link by visiting AtomicHub marketplace (if you're familiar) and going to 'API' at the bottom of the page.
And specifically it seems you want to use the following API:
https://wax.api.atomicassets.io/atomicassets/v1/assets?owner={account name}
You would still use waxjs along with this, to login the user and get his {account name} for the query above. You could then use the 'api' object in waxjs to do transactions. You can read more about that object here: https://developers.eos.io/manuals/eosjs/latest/API-Reference/classes/eosjs_api.api