1.0.17 • Published 1 year ago

gari v1.0.17

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

gari-sdk

This SDK is easy-to-use wallet service that a client can use to enable their users to have their wallet within there application and do on-chain transactions within their app

💡 Features

  • Create a wallet for a user
  • fetch their wallet details and balance for a particular user
  • Send gari tokens from one wallet to another
  • fetch their transaction details by txn id
  • Client can Airdrop gari tokens to its users

⚡ Quick Start

Installation

npm install gari
import * as gari from 'gari'

Method List

  • sdkInitialize
  • createWalletOrGetWallet
  • transferGariToken
  • airdrop
  • initiateTransaction
  • getTransactions
  • getTransactionById

Frontend Methods

Initialize gari library

/**
 * @description 
 * @param {string} clientId 
 */
gari.sdkInitialize(clientId)

createWallet Or GetWallet

Get wallet or create wallet for user.

Token format supported: here

Note: web3 auth popup will occur initiale for user during wallet creation, next time this function will directly return data

/**
 * @param {string} token
 */
gari.createWalletOrGetWallet(token)
 
return {
publicKey:’sample publickey’,
balance:0
} 

transferGariToken

Send gari token to another user. This will return encoded transaction which client has to send to its backend for validation and its backend will forward it to chingari for processing.

/**
 * @param {string} token
 * @param {string} toPublicKey
 * @param {number} amount
 * @returns 
 */
gari.transferGariToken(token,toPublicKey, amount)

return
{
transaction:’base64 Encoded Tranaction’
}

Backend Methods

Initialize gari library

/**
 * @description if using in backend, need to pass gariSecretKey
 * @param {string} clientId 
 * @param {string?} secerateKey 
 */
gari.sdkInitialize(clientId,secerateKey)

airdrop

client will airdrop gari tokens to its users as a reward.

/**
 * @param {string} publicKey 
 * @param {number} amount 
 * @param {string} token 
 * @param {string} fromWalletPrivateKey 
 * @returns 
 */
gari.airdrop(publicKey,amount,token,fromWalletPrivateKey)

return
{
id:’’,
signature:'EJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVmsdgEJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVm',
status:’draft|pending|success|failed’,
message:’’
}

initiateTransaction

This method will validate transaction details and return signature.

/**
 * @param {string} encodedTransaction 
 * @param {string} token 
 */
gari.initiateTransaction(encodedTransaction,token)

return 
{
siganature:'EJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVmsdgEJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVm'
}

getTransactions

this will give all client related transactions to sdk Client.

/**
 * @param {object} filter 
 * @param {number} skip 
 * @param {number} limit 
 * @param {string} sorting 
 * @param {string} token 
 * @returns 
 */
gari.getTransactions(filter,skip,limit,sorting,token)

filter
{
fromPublicKey:’’,
toPublicKey:’’,
Status:’’,
case:’’
}

return
[{
id:’’,
signature:'EJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVmsdgEJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVm',
status:’draft|pending|success|failed’,
amount:number,
meta:string,
date:Date
}]

getTransactionById

this will return specific transaction by particular id.

/**
 * @param {string} transactionId 
 * @param {string} token
 * @returns 
 */
gari.getTransactionById(transactionId,token)

return
{
id:’’,
signature:'EJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVmsdgEJ3FktdZhsNbDMamvSygi2wLfjBgisWzF1iNecdckQVm',
status:’draft|pending|success|failed’,
amount:number,
meta:string,
date:Date
}

🌐 Demo

Checkout the gari Demo to see how gari can be used in your application. Demo Source code

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago