# Wallet API endpoints

The latest documentation for endpoints is always on the DevPortal: <https://partner.socios.com/devportal/apis/1464738d-213b-4073-8599-46b63390a6ea/test>

{% openapi src="/files/Eia5oxOIBgs21VRUDy1V" path="/user/wallet" method="get" %}
[wallet.json](https://31329255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMDcaoJLMj5Y3jzFMTONF%2Fuploads%2FnT5LAJN0Iy67xpww39w5%2Fwallet.json?alt=media\&token=33d0368b-03ab-4e83-908c-63844a36d734)
{% endopenapi %}

{% hint style="success" %}
:arrow\_down: **ALTERNATIVE: Retrieve User Token Balance** :arrow\_down:<br>
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import { createPublicClient, http } from 'viem';
import { abi as erc20ABI } from './ERC20ABI.json';

const client = createPublicClient({
  transport: http('https://rpc.ankr.com/chiliz'),
});

const tokenAddress = '0xYourTokenAddress'; // Replace with the actual ERC-20 contract address
const userAddress = '0xUserWalletAddress'; // Replace with the user's wallet address
async function getTokenBalance() {
  const balance = await client.readContract({
    address: tokenAddress, // Contract address of the token
    abi: erc20ABI, // ERC-20 ABI
    functionName: 'balanceOf', // Standard ERC-20 function to get balance
    args: [userAddress], // User's address whose balance you want to check
  });
  return balance.toString();
}
// Example usage
getTokenBalance().then(console.log);
```

{% endcode %}

{% openapi src="/files/Eia5oxOIBgs21VRUDy1V" path="/user/wallet/sign-message" method="post" %}
[wallet.json](https://31329255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMDcaoJLMj5Y3jzFMTONF%2Fuploads%2FnT5LAJN0Iy67xpww39w5%2Fwallet.json?alt=media\&token=33d0368b-03ab-4e83-908c-63844a36d734)
{% endopenapi %}

{% hint style="danger" %}
REMOVED WITH NO ALTERNATIVE AVAILABLE
{% endhint %}

{% openapi src="/files/Eia5oxOIBgs21VRUDy1V" path="/user/wallet/{transactionId}" method="get" %}
[wallet.json](https://31329255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMDcaoJLMj5Y3jzFMTONF%2Fuploads%2FnT5LAJN0Iy67xpww39w5%2Fwallet.json?alt=media\&token=33d0368b-03ab-4e83-908c-63844a36d734)
{% endopenapi %}

{% hint style="success" %}
:arrow\_down: **ALTERNATIVE: Retrieve a User's Transaction** :arrow\_down:
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```javascript
async function getTransaction(txHash) {
  const transaction = await client.getTransaction({
    hash: txHash, // Replace with the actual transaction hash
  });
  return transaction;
}

// Example usage
getTransaction('0xTransactionHash').then(console.log);
```

{% endcode %}

{% openapi src="/files/Eia5oxOIBgs21VRUDy1V" path="/user/wallet/transaction-history/fan-token" method="get" %}
[wallet.json](https://31329255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMDcaoJLMj5Y3jzFMTONF%2Fuploads%2FnT5LAJN0Iy67xpww39w5%2Fwallet.json?alt=media\&token=33d0368b-03ab-4e83-908c-63844a36d734)
{% endopenapi %}

{% openapi src="/files/Eia5oxOIBgs21VRUDy1V" path="/admin/wallet/transfer/fan-token" method="post" %}
[wallet.json](https://31329255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMDcaoJLMj5Y3jzFMTONF%2Fuploads%2FnT5LAJN0Iy67xpww39w5%2Fwallet.json?alt=media\&token=33d0368b-03ab-4e83-908c-63844a36d734)
{% endopenapi %}

{% hint style="success" %}
:arrow\_down: **ALTERNATIVE: Send ERC-20 Tokens to a User Wallet** :arrow\_down:
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import { createWalletClient, privateKeyToAccount } from 'viem';

const privateKey = '0xSenderPrivateKey'; // Replace with the sender's private key
const account = privateKeyToAccount(privateKey);
const walletClient = createWalletClient({
  account,
  transport: http('https://rpc.ankr.com/chiliz'),
});
async function sendTokens(to, amount) {
  const txHash = await walletClient.writeContract({
    address: '0xYourTokenAddress', // Replace with the ERC-20 token contract address
    abi: erc20ABI, // ERC-20 ABI
    functionName: 'transfer', // Standard ERC-20 function to transfer tokens
    args: [to, BigInt(amount * 1e18)], // Replace 'to' with recipient address and 'amount' with the amount to send
  });
  return txHash;
}
// Example usage
sendTokens('0xRecipientAddress', 10).then(console.log);

```

{% 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://connect.socios.com/partner-api/api-reference/wallet-api/wallet-api-endpoints.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.
