RetrieveUser
This function retrieves information about the currently logged in user. The fields returned include the userIdentifier, the user's wallet addresses, and the asset and collectibles balances.
This function should only be invoked once the user has successfully logged in.
async RetrieveUser(apiKey)
Parameter | Type | Definition |
---|---|---|
apiKey | String |
This function returns a
Promise
that resolves to the following object:{
"statusCode": 1/0,
"data": {
"userIdentifier": "userIdentifier", // the userIdentifier returned from your JWT verification endpoint
"chainWallets": [
"eth": [
"address" // list of addresses for each chain
],
...
], // list of wallet addresses for each chain
"assets": [
"eth_eth": { // assetKey
"totalBalance": "totalBalance", // total balance in BigNumber, across all user accounts
"accountBalances": [
{
"address": "address", // wallet address
"balance": "balance" // balance in BigNumber
},
]
},
...
], // list of assets owned by user
"collectibles": [
{
/****** Metafi Asset fields *******/
"symbol": "",
"chain": {
/* Metafi chain Object */
},
"decimals": 0,
"isNative": false,
"contractAddress": "contractAddress",
"assetKey": "",
"className": "Asset",
"tokenStandard": {
"name": "erc1155"
},
/****** NFT specific fields *******/
"name": "name", // name extracted from NFT metadata
"image": "imageURL", // image URL extracted from NFT metadata
"description": "description", // description extracted from NFT metadata
"tokenUri": "tokenUri", // fetched from smart contract
"metadata": { // raw NFT metadata extracted from token URI
"name": "name",
"description": "description",
"image": "imageURL",
},
"tokenId": "tokenId" // fetched from smart contract
},
...
],
}
"error": "error" // error if any
}
custom-tokens.js
1
import { RetrieveUser } from '@metafi/metafi-js-package';
2
3
function App() {
4
// Login logic
5
6
const handleRetrieveUser = async () => {
7
var result = await RetrieveUser("YOUR-API-KEY");
8
console.log("result after retrieving user", result);
9
}
10
11
return (
12
<div>
13
<button onClick={handleRetrieveUser}>Retrieve User Details</button>
14
</div>
15
);
16
}
17
18
export default App;
19
Last modified 2mo ago