@getsafle/asset-controller

1.0.12 • Public • Published

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 Address
  • tokenType - 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 addresses
  • SINGLE_CALL_BALANCES_ADDRESS - Contract address of the single call balance checker contract
  • userAddress - Public address of the user to query the balance of

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.120latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.120
1.0.110
1.0.101
1.0.90
1.0.80
1.0.70
1.0.61
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @getsafle/asset-controller

Weekly Downloads

2

Version

1.0.12

License

MIT

Unpacked Size

12.4 kB

Total Files

11

Last publish

Collaborators

  • subhanshugupta
  • apoorv31
  • shubham.3008
  • sidth