Skip to content

Balance Check and Fetch details of TradeToken

To retrieve details and check the balance of a trade token, you can use the TradeTokenContract class from the skc-sdk. Here are the steps:

Initialize the TradeTokenContract

You need to initialize the TradeTokenContract with the contract address, a signer or provider, and the RPC URL.

javascript
import { TradeTokenContract } from "skc-sdk";
const provider = new ethers.JsonRpcProvider("http://localhost:8545");
const signer = provider.getSigner();
const tradeToken = new TradeTokenContract("0xYourTradeTokenContractAddress", signer, "http://localhost:8545");

Retrieve Token Details

Use the getDetails method to fetch all relevant details of the trade token.

javascript
const details = await tradeToken.getDetails();
console.log(details);

This method returns a promise that resolves to an object containing the token's name, symbol, owner, decimals, total supply, balances, and attachments.

Check Balance of a Specific Address

Use the getBalance method to fetch the balance of a specific address.

javascript
const balance = await tradeToken.getBalance("0xUserAddress");
console.log(balance);

This method takes an address as a parameter and returns a promise that resolves to the balance of the specified address.

By following these steps, you can retrieve the details and check the balance of a trade token using the TradeTokenContract class.