Skip to content

getsafle/custom-token-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Token Controller

This SDK can be used to get the details of any token by it's contract address and it's balance for a specific address.

Installation

To install this SDK,

npm install --save @getsafle/custom-token-controller

Initialization

Initialize the constructor,

const safleTokenController = require('@getsafle/custom-token-controller');

const tokenController = new safleTokenController.CustomTokenController({ userAddress, rpcURL, chain });
  • userAddress - User Public Address
  • rpcURL - Web3 RPC provider URL
  • chain - blockchain name

Get Token Details


This function returns the token decimal and symbol for the contract address passed as parameter.

const tokenDetails = await tokenController.getTokenDetails(contractAddress);
  • contractAddress - Token contract address

Get Token Balance


const tokenDetails = await tokenController.getTokenBalance(contractAddress);
  • contractAddress - Token contract address