Initializing the client

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.

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

Examples

For your Testing environment

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.(userWalletAddress);

// sync does not need to be called again as long as this instance exists
console.log(userClientFromClient.id); // > ABC123

For your Production environment

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);

Last updated