> For the complete documentation index, see [llms.txt](https://xact.gitbook.io/xact/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xact.gitbook.io/xact/sdk/javascript/transfer-a-token.md).

# Transfer a Token

This sample will show you how to prompt for a token transfer. We will first generate a request for the end user. Once validated, you will get notified about transaction's status.

## Prerequisites: <a href="#pre-requisites" id="pre-requisites"></a>

{% content-ref url="/pages/-Mg56\_a4eJ5VygETYHMC" %}
[Getting started](/xact/sdk/javascript/getting-started.md)
{% endcontent-ref %}

## Step 1: Import the following modules

Let's continue building on the *index.js* from the previous example ([Environment Set-up](/xact/sdk/javascript/getting-started.md#step-1-set-up-your-node-js-environment)) and add the following modules:

```typescript
const { Client } = require("@xact-wallet-sdk/client");
require("dotenv").config();
```

## Step 2: Get Xact Fees

In order to get the fees from our service, you need to proceed as below

```typescript
const xactFees = await client.getXactFeesTransfer();
```

## Step 3: Initializing Token Transfer

When initializing a token transfer, a request will be sent to the end user

```typescript
/* Update the fields with your informations */
const fromAccountId = '';
const toAccountId = '';
const tokenToTransfer = '';

await client.transfer({fromAccountId, toAccountId, tokenId: tokenToTransfer});
```

## Step 4: Listen for the Token Transfer

Finally get notified when a new token association has been done successfully !

```typescript
/* Subscribe to new Token Transfer */
client.transferValidation().subscribe(token => {
    console.log('Transfer Token', token);
});
```

## Code Check ✅

Your *index.js* file should look like this:

{% code title="index.js" %}

```typescript
const { Client } = require("@xact-wallet-sdk/client");
require("dotenv").config();

async function associate() {

    //Grab your api key from your .env file
    const apiKey = process.env.API_KEY;


    // If we weren't able to grab it, we should throw a new error
    if (apiKey == null) {
        throw new Error("Environment variables API_KEY must be present");
    }
    /* Create a new instance of Client */
    const client = new Client({apiKey});
    
    /* Init the connexion */
    await client.initConnexion();
    
    /* Update the fields with your informations */
    const fromAccountId = '';
    const toAccountId = '';
    const tokenToTransfer = '';
    
    /* Request for transfer */
    await client.transfer({fromAccountId, toAccountId, tokenId});
    
    /* Listen for transaction success */
    client.transferValidation().subscribe(token => {
        console.log('New transfer token', token);
    });
}

associate();
```

{% endcode %}
