@getsafle/asset-controller
v1.0.12
Published
This controller detects tokens for a user and returns token balances.
Downloads
9
Keywords
Readme
Safle Asset Controller
This SDK is used to detect the tokens and their balances in a given user's public address.
Installation
To install this SDK,
npm install --save @getsafle/asset-controller
Initialization
Initialize the constructor,
const safleAssetController = require('@getsafle/asset-controller');
const assetController = new safleAssetController.AssetController({ rpcURL, chain });
Detect Tokens
This function will detect and return the list of all the tokens in the user's public address.
const tokenBalance = await assetController.detectTokens({ userAddress, tokenType });
userAddress
- User Public AddresstokenType
- optional parameter - valid values- erc20/erc721
Get list of chains on which a token exists
This function will return the list of all the chains which a particular token is supported
const chains = await assetController.getChains(tokenSymbol);
tokenSymbol
- Token Symbol
Get token balances
This function will return the balances of all the tokens contract addresses passed in the array
const chains = await assetController.getTokenBalances(tokensToDetect, SINGLE_CALL_BALANCES_ADDRESS, userAddress);
tokensToDetect
- array of all the token addressesSINGLE_CALL_BALANCES_ADDRESS
- Contract address of the single call balance checker contractuserAddress
- Public address of the user to query the balance of