@hinkal/api
v0.1.5
Published
The `@hinkal/api` package provides a comprehensive set of functions to interact with the Hinkal Protocol backend services. It is designed to handle various operations such as user KYC verification, password management, transaction processing, price retrie
Downloads
452
Keywords
Readme
Overview
The @hinkal/api
package provides a comprehensive set of functions to interact with the Hinkal Protocol backend services. It is designed to handle various operations such as user KYC verification, password management, transaction processing, price retrieval, and more. This documentation provides a brief overview of the available API methods, their purposes, and usage examples.
Installation
To install the @hinkal/api
package, use npm or yarn:
npm install @hinkal/api
yarn add @hinkal/api
Usage
Import the API into your project:
import { API } from '@hinkal/api';
API Methods
KYC (Know Your Customer)
Handles user verification processes.
getUserKycStatus(chainId, ethereumAddress)
Retrieves the KYC status of a user based on their Ethereum address and the specified blockchain network.
- Parameters:
chainId
(Chain
): The identifier of the blockchain network.ethereumAddress
(string
): The user's Ethereum address.
- Returns:
Promise<IGetKycStatus>
setAiPriseVerificationUrl(chainId, ethereumAddress, verificationSessionId, verificationType)
Initiates the KYC verification process by setting the verification URL.
- Parameters:
chainId
(Chain
)ethereumAddress
(string
)verificationSessionId
(string
)verificationType
(VERIFICATION_TYPE
)
- Returns:
Promise<any>
getAccessTokenSignature(chainId, ethereumAddress, accessKey)
Obtains a signature for an access token.
- Parameters:
chainId
(Chain
)ethereumAddress
(string
)accessKey
(string
)
- Returns:
Promise<AccessTokenSignatureResponse>
getZkMeAccessToken(chainId)
Fetches the ZkMe access token for the specified blockchain network.
- Parameters:
chainId
(Chain
)
- Returns:
Promise<string>
userHasAccessToken(chainId, accessKey)
Checks if a user possesses a valid access token.
- Parameters:
chainId
(Chain
)accessKey
(string
)
- Returns:
Promise<{ hasAccessToken: boolean }>
afterKycCall(chainId, ethereumAddress, hasAccessTokenOnAnyChain)
Performs post-KYC operations after verification.
- Parameters:
chainId
(Chain
)ethereumAddress
(string
)hasAccessTokenOnAnyChain
(boolean
)
- Returns:
Promise<{ updated: boolean }>
Password Management
Handles user password operations.
userHasPassword(chainId, ethereumAddress)
Checks if a user has a password set.
- Parameters:
chainId
(Chain
)ethereumAddress
(string
)
- Returns:
Promise<OptionalUserPassword>
userRegisterPassword(chainId, ethereumAddress, passwordHash)
Registers a password for a user.
- Parameters:
chainId
(Chain
)ethereumAddress
(string
)passwordHash
(string
)
- Returns:
Promise<UserPassword>
Relay Operations
Manages transaction relaying.
getIdleRelay(chainId)
Retrieves an idle relay server for transaction processing.
- Parameters:
chainId
(Chain
)
- Returns:
Promise<IGetIdleRelay>
callRelayerTransactAPI(chain, requestBody)
Sends a transaction request to the relay server.
- Parameters:
chain
(Chain
)requestBody
(HinkalTransactionRequestBody
)
- Returns:
Promise<any>
Price Retrieval
Fetches token prices from various sources.
getTokenPrice(chainId, erc20Address?, id?)
Retrieves the price of a specific ERC20 token.
- Parameters:
chainId
(Chain
)erc20Address
(string
, optional)id
(string
, optional)
- Returns:
Promise<GetTokenPriceInterface>
getTokenPriceEth(chainId, id)
Gets the price of a token in ETH.
- Parameters:
chainId
(Chain
)id
(string
)
- Returns:
Promise<GetTokenPriceEthInterface>
getTokenPrices(chainId, erc20Addresses)
Retrieves prices for multiple ERC20 tokens.
- Parameters:
chainId
(Chain
)erc20Addresses
(string[]
)
- Returns:
Promise<IGetPrices>
getOdosPriceForToken(chainId, tokenAddress)
Fetches the Odos price for a specific token.
- Parameters:
chainId
(Chain
)tokenAddress
(string
)
- Returns:
Promise<number | undefined>
callOdosAPI(chainId, requestBody)
Calls the Odos API for token swaps.
- Parameters:
chainId
(Chain
)requestBody
(OdosSwapRequest
)
- Returns:
Promise<any>
Coingecko Sub-Methods
getCoingeckoPrice(tokenId)
Retrieves the price of a token from Coingecko.
- Parameters:
tokenId
(string
)
- Returns:
Promise<CoingeckoPriceResponse>
getCoingeckoPrice2(tokenAddress, platform)
Fetches the price based on token address and platform.
- Parameters:
tokenAddress
(string
)platform
(string
)
- Returns:
Promise<CoingeckoPriceResponse>
getCoingeckoPrices(tokenIds)
Retrieves prices for multiple tokens from Coingecko.
- Parameters:
tokenIds
(string
)
- Returns:
Promise<CoingeckoPricesResponse>
getCoingeckoTokenList()
Gets the list of tokens available on Coingecko.
- Returns:
Promise<CoingeckoToken[]>
Transaction Management
Handles user transactions and their verification.
verificationStartDate(chainId, ethereumAddress)
Retrieves the start date for transaction verification.
- Parameters:
chainId
(Chain
)ethereumAddress
(string
)
- Returns:
Promise<IVerificationStartDate>
userGetTransactions(chainId, week?, lastHash?)
Fetches user transactions.
- Parameters:
chainId
(Chain
)week
(number
, optional)lastHash
(string
, optional)
- Returns:
Promise<IUserGetTransactions>
userVerifyTransactions(chainId, transactionHashes, zkCallDataArray, backendToken, ethereumAddress, week)
Verifies user transactions.
- Parameters:
chainId
(Chain
)transactionHashes
(string[]
)zkCallDataArray
(NewZkCallDataType[]
)backendToken
(string
)ethereumAddress
(string
)week
(number
)
- Returns:
Promise<IUserVerifyTransactions>
Snapshots
Manages snapshots of commitments and access tokens.
fetchCommitmentsSnapshot(chainId)
Retrieves a snapshot of commitments.
- Parameters:
chainId
(Chain
)
- Returns:
Promise<ICommitmentsTreeSnapshot>
fetchAccessTokenSnapshot(chainId)
Fetches a snapshot of access tokens.
- Parameters:
chainId
(Chain
)
- Returns:
Promise<IAccessTokenTreeSnapshot>
restoreSnapshots(chainId)
Restores snapshots to the backend.
- Parameters:
chainId
(Chain
)
- Returns:
Promise<any>
Nullifiers
Handles nullifier data for privacy operations.
fetchNullifiers(chainId)
Retrieves nullifiers from the backend.
- Parameters:
chainId
(Chain
)
- Returns:
Promise<GetNullifiersResponse>
Risk Management
Evaluates the risk associated with user actions.
checkRisk(chain, address)
Checks the risk level for a specific address on a given chain.
- Parameters:
chain
(Chain
)address
(string
)
- Returns:
Promise<any>
Monitoring
Monitors user addresses for specific events or transactions.
monitor(address, chain)
Initiates monitoring for a user address.
- Parameters:
address
(string
)chain
(Chain
)
- Returns:
Promise<void>
Gas Estimates
Provides gas estimates for transactions.
getGasEstimates(chainId, tokenAddress, externalActionId, erc20TokenAddressLength, gasAmount?)
Retrieves gas estimates for a transaction.
- Parameters:
chainId
(Chain
)tokenAddress
(string
)externalActionId
(ExternalActionId
)erc20TokenAddressLength
(number
)gasAmount
(number
, optional)
- Returns:
Promise<GetGasEstimateResponse>
/ End of Selection