For when you intend to complete a requirement for a user programmatically.
Intended uses
When you are dealing with a requirement that can only be completed by your system, and not ChainVine's, some examples can include, but is not limited to:
a user interacts with a chain that ChainVine does not support
a user replies to a message on your app
a user signs up for an off-chain feature on your app
To better understand how a reward is issued to a user when calling this method, please refer to the completeRequirement method
Before implementing this approach, be sure to have whitelisted your domain.
import { ChainvineClient } from'@chainvine/sdk';constclient=newChainvineClient();constwallet_address='0x1234567890'//<-- supplied by your systemsconsttransaction_hash='0x1234567890'; //optionalconsttoken_address='0x1234567890'; //optionalconstamount=100; // this is the amount of token you want us to convertconstusd_value=100; //optional, the USD value of the token at the time of the conversionconstexternal_identifier='ABC123'; //optional (e.g. a user ID in your system)constfee=390;constcampaign= { id:'aSlug123'}constuserClient=awaitclient.syncUser(wallet_address);constres=awaituserClient.transferEvent({ campaign, transaction_hash, token_address, amount, usd_value, external_identifier, fee,});
Before implementing this approach, be sure to have gotten a copy of your API Key.
import { ChainvineClient } from'@chainvine/sdk';constclient=newChainvineClient({ apiKey:'9dj022didj',//your api key});constwallet_address='0x1234567890'//<-- supplied by your systemsconsttransaction_hash='0x1234567890'; //optionalconsttoken_address='0x1234567890'; //optionalconstamount=100; // this is the amount of token you want us to convertconstusd_value=100; //optional, the USD value of the token at the time of the conversionconstexternal_identifier='ABC123'; //optional (e.g. a user ID in your system)constcampaign= { id:'aSlug123'}constuserClient=awaitclient.syncUser(wallet_address);constres=awaituserClient.completeRequirement({ campaign, id: requirementId, referrer_id, transaction_hash, token_address, amount, usd_value, external_identifier,});