# Initializing the client

```typescript
import { ChainvineUser } from '@chainvine/sdk';

const config = {
   apiKey: 'S3CR37C0D3Z',
   testMode: true,
   logToConsole: true,
}

const client = new ChainvineClient(config)

// By default we assume you are dealing with an ethereum wallet address 
const userClient = await client.syncUser('0x393849393430')

// If your users are uniquely identified by an email address or you would like to
// use your own internal unique identifier you may instead use either of the following
const userClient = await client.syncUserWithEmail('user@test.xyz')
const userClient = await client.syncUserWithExternalId('myOwnInternalId123')
```

You may provide an optional configuration parameters in order to override the [default settings of the Client](broken://pages/4DdnEIPn6ZrnRUFs7uVC).

You may then use the userClient to perform actions specific to the user it was synced with

## Examples

### **For your Testing environment**

{% tabs %}
{% tab title="Node.js/JavaScript" %}

<pre class="language-javascript"><code class="lang-javascript">import { ChainvineClient } from '@chainvine/sdk';

const config = {
   apiKey: 'S3CR37C0D3Z',
   testMode: true,
   logToConsole: true,
}

const userWalletAddress = '0x393849393430'

const client = new ChainvineUser(config);

// Create your ChainvineUser client
const userClient = new ChainvineUser(
   userWalletAddress, 
   config
);

// or by using the syncUser method (note this will create or fetch the user
// on ChainVine
const userClientFromClient = await client.<a data-footnote-ref href="#user-content-fn-1">syncUser</a>(userWalletAddress);
<strong>
</strong><strong>// sync does not need to be called again as long as this instance exists
</strong><strong>console.log(userClientFromClient.id); // > ABC123
</strong></code></pre>

{% endtab %}
{% endtabs %}

### For your Production environment

{% tabs %}
{% tab title="Node.js/JavaScript" %}

```javascript
import { ChainvineClient } from '@chainvine/sdk';

const config = {
   apiKey: 'S3CR37C0D3Z',
   logToConsole: true, //can also be false or ommited depending on your needs
}

const userWalletAddress = '0x393849393430'

const client = new ChainvineClient(config);

// Create your ChainvineUser client
const userClient = await client.syncUser(userWalletAddress);
```

{% endtab %}
{% endtabs %}

[^1]:


---

# 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.chainvine.xyz/developers/sdk/classes-and-functions/chainvineuser/initializing-the-client.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.
