import { ChainvineUser } from'@chainvine/sdk';constconfig= { apiKey:'S3CR37C0D3Z', testMode:true, logToConsole:true,}constclient=newChainvineClient(config)// By default we assume you are dealing with an ethereum wallet address constuserClient=awaitclient.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 followingconstuserClient=awaitclient.syncUserWithEmail('user@test.xyz')constuserClient=awaitclient.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
For your Production environment
import { ChainvineClient } from'@chainvine/sdk';constconfig= { apiKey:'S3CR37C0D3Z', logToConsole:true,//can also be false or ommited depending on your needs}constuserWalletAddress='0x393849393430'constclient=newChainvineClient(config);// Create your ChainvineUser clientconstuserClient=awaitclient.syncUser(userWalletAddress);
import { ChainvineClient } from'@chainvine/sdk';constconfig= { apiKey:'S3CR37C0D3Z', testMode:true, logToConsole:true,}constuserWalletAddress='0x393849393430'constclient=newChainvineUser(config);// Create your ChainvineUser clientconstuserClient=newChainvineUser( userWalletAddress, config);// or by using the syncUser method (note this will create or fetch the user// on ChainVineconstuserClientFromClient=awaitclient.(userWalletAddress);// sync does not need to be called again as long as this instance existsconsole.log(userClientFromClient.id); // > ABC123