1.0.0 • Published 2 years ago

cl3-af v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

CL3

With this SDK, including affiliate marketing into your application is simple and clear.

Get started

npm i cl3-affilink

All of the prerequisites required to use this SDK are installed by this command.

Initializing Constructor

The provider(window) is necessary to initialize the constructor.

const cl3 = new CL3(window, walletAddress)

Create an instance for a class by using the above line of code. Later, the functions included in the SDK will be called using this instance.

Deploy Contracts

- Contract deployment is made possible by this feature.

Parameters

WasmCode

Uint8Array(obtained by converting wasm file to buffer and then buffer to an Uint8Array)

InstantiateMsg

Parameters required for contract deployment

Label

Any string that specifies the contract

Source code

const response = await cl3.deploy(wasmCode, instantiateMsg, lebel)

Returns

- Contract address.

Add Subscription Plans

- Here the admin can add as many plans as he wants. 
- The administrator cannot add an identical plan that was already in existence.
- Plan addition is restricted to admins only.

Parameters

PlanName

The name of the necessary subscription plan to add

Price

The cost of the appropriate plan

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.addPlan(planName, price, cl3ContractAddress)

Add Referral

- Here the referral can be joined to the network. 

- While joining, the referral is restricted by 3 conditions.
    - Referral can’t be an invalid address.
    - Referral can’t be his own referrer.
    - Referral can’t be one of the referrer's up lines.

- Once these three conditions pass then the users can be joined to the MLM network under their referrer’s first level(immediate level).

- After the referral joins, our contract will automatically update the presence of the newly joined referral to all the upline members of his immediate parent(the person who referred him).

Parameters

Referrer address

wallet address of the person who referred the user.

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.addReferral(referrer, cl3ContractAddress)

Pay Referral

- Depending on the organization's needs, this function will carry one of the following two actions.

- If the organization wants to send reward to the immediate person alone, then the referral should send a certain proportion of the total amount in tokens to the person who referred him. The admin account will receive the tokens that are left over.

- If the organization wants to send reward upto the certain level, Users of the MLM network have to pay commission to the immediate referrer and as well as to the upline members of the network up to the level set by the organization. The admin account will receive the tokens that are left over.

- The referral must have sufficient tokens to unlock the subscription plan at the time of payment. If not then the user has to buy tokens. 

Parameters

PlanName

Plan name of the particular subscription plan to which the user would like to subscribe

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.payReferral(planName, cl3ContractAddress)

Buy Tokens:

- Users can buy tokens here by sending the native currency of the blockchain needed to join the MLM network.

- Once the transaction of native blockchain currency is successful then the tokens will be transferred from the treasury account to the referral who requested  tokens

Parameters

Amount

Amount needed to buy the tokens

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.buyTokens(amount, cl3ContractAddress)

Get referral detail

- This will return one particular user's detail. 

Parameters

Wallet Address

wallet address of the user

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.getReferralDetail(walletAddress, cl3ContractAddress)

Get all referral details

- This will return all the referral details. 

Parameters

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.getAllReferralDetail(cl3ContractAddress)

View Plan

- The administrator can get the available subscription plan details

Parameters

PlanName

Name of the specific plan for which information is needed

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.getPlanDetail(planName, cl3ContractAddress)

Returns

-The plan information, including the name and cost of the plan.

View All Plans

- The administrator can retrieve all the available subscription plan details at once.

Parameters

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.getAllPlanDetails(cl3ContractAddress)

Check Payment Status

- Can verify whether a user has made a payment or not. 

Parameters

WalletAddress

The wallet address of the user has to be verified.

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.getPaymentStatus(walletAddress, cl3ContractAddress)

Returns

- Payment status would be returned as true if the user paid, otherwise false.
- If the user made a successful payment, it will also return the name of the paid subscription plan.

Get Level Detail

- This will provide level-specific information about a specific referral.

Parameters

Level count

level count of a specific level which details are trying to obtain.

Wallet Address

wallet address of the user

ContractAddress

Contract address of cl3-contract

Source Code

const response = await cl3.getLevelDetail(walletAddress, levelCount, cl3ContractAddress)

Set Allowance

- Users must authorize the contract before transferring tokens from their accounts to other users/admins. 
- This functionality enables the user to determine an allowance.

Parameters

Spender

The address of the contract which transfers the tokens from the user to the recipient

Amount The number of tokens that need to transfer to the recipient

ContractAddress

Contract address of token-contract

Source Code

const response = await cl3.setAllowance(spender, amount, tokenContractAddress)

GetAllowance

- Used to check how much allowance is provided by the owner to the spender.

Parameters

Owner

wallet address of the user

Spender

wallet address of the spender

ContractAddress

Contract address of token-contract

Source Code

const response = await cl3.allowance(owner, spender, tokenContractAddress)

Returns

- Returns how much tokens the spender can use from the owner's account.