# RetrieveUser

## Description

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.

## Details

### Signature

`async RetrieveUser(apiKey)`

### Arguments

<table><thead><tr><th width="258">Parameter</th><th width="114">Type</th><th>Definition</th></tr></thead><tbody><tr><td><code>apiKey</code></td><td>String</td><td>The API Key generated from the <a href="https://developer-test.usemeta.fi/">Developer Portal</a></td></tr></tbody></table>

### Return Value

This function returns a `Promise` that resolves to the following object:

```json
{
    "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
}

```

## Example

{% code title="custom-tokens.js" lineNumbers="true" %}

```jsx
import { RetrieveUser } from '@metafi/metafi-js-package';

function App() {
    // Login logic
    
    const handleRetrieveUser = async () => {
        var result = await RetrieveUser("YOUR-API-KEY");
        console.log("result after retrieving user", result);
    }
    
    return (
        <div>
	    <button onClick={handleRetrieveUser}>Retrieve User Details</button>
        </div>
    );
}

export default App;

```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.usemeta.fi/js-sdk/sdk-reference/retrieveuser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
