Holdstation Docs
  • πŸ‘‹Welcome
  • Overview
    • πŸ’‘Introduction
      • πŸ†Achievements
      • πŸ‘“Future Direction
      • πŸ’₯Product Suite
      • ⛓️Chain Support
      • 🀝Team
      • πŸ—ΊοΈRoadmap
      • πŸ”Audit
    • πŸ«‚Product Fit Community
      • Why Product Fit Community?
      • The Unique Cultures of Blockchain Communities
      • Holdstation’s Community Focus
      • Holdstation Across Ecosystems
    • πŸ‘₯Referral Program
      • πŸ’΅USDC Reward
    • πŸ”—Link
  • Holdstation on World Chain
    • πŸ‘οΈWhy World Chain?
    • πŸͺͺSmart Wallet for Real Users
    • πŸ’ΉAION
    • πŸ₯šEggs Vault: Gamified Rewards
  • 🐻Berachain's HONEY Hub
    • ❓Why Berachain
    • 🟑berAIs.land
    • πŸ’±Holdstation DEX Aggregator
      • How to Integrate?
      • Liquidity Sources
      • Fee Structures
    • πŸ’³DeFAI Smart Wallet
      • πŸ“¦Holdstation Chest
    • πŸ’ΉBeFutures Perp
      • πŸ—οΈArchitecture
        • πŸ’‘Dynamic Price Feed (DPF)
        • πŸ’ΉFlexible Market Making (FMM)
        • πŸ”ŒLeverage
        • 🧲Margin Requirement
        • 🀫Liquidation
        • πŸ’²BeFuture Fees
        • 🏧BeFuture Vault
    • πŸš€Berastarter
      • ❓How does the Fair Subscription model work?
      • 🎯Affiliate Reward
    • 🏨Holdstation Foundation
      • πŸ‘·DAO Structure
      • πŸ‘‰How to be qualified?
    • πŸ‘¨β€πŸ’»AI Communication
  • Holdstation on Solana
    • 🟣Why Solana?
    • πŸ€–Smart Wallet for AI Trading
  • Token
    • πŸ“ˆToken Overview
      • πŸš€Tokenomics
      • πŸ“ͺToken Utility
      • πŸ”Token Migration
      • πŸ’ͺSustainable Expansion
    • πŸ“”Contract Address
    • πŸ”‘Multisig Wallet
    • πŸ—“οΈHoldstation Public Sales (Ended)
  • User Guide
    • πŸ“ͺSpot Trading
    • πŸ“ŽMargin Trading
    • πŸŒ‰Bridging
    • ⚑Vault
    • 🟣HOLD Staking
  • Integration
    • πŸ“šHoldstation/Worldchain-SDK
      • πŸ‘οΈTokens and Balances
      • ⏫Send
      • πŸ’±Swap
      • πŸŒ‰Widget
      • πŸ“–History
  • Disclaimer
    • πŸ“•Disclaimer
Powered by GitBook
On this page
  • Installation
  • Setup
  • Get Token Metadata
  • πŸ“‘ Parameters
  • πŸ“˜ Usage
  • Get All Tokens Held by a Wallet
  • πŸ“‘ Parameters
  • πŸ“˜ Usage
  • Get Balances of Multiple Tokens for One Wallet
  • πŸ“‘ Parameters
  • πŸ“˜ Usage
  • Get Balance of a Single Token for Multiple Wallets
  • πŸ“‘ Parameters
  • πŸ“˜ Usage
  1. Integration
  2. Holdstation/Worldchain-SDK

Tokens and Balances

PreviousHoldstation/Worldchain-SDKNextSend

Last updated 21 days ago

The TokenProvider class from @holdstation/worldchain-sdk enables developers to interact with token metadata, balances, and wallet holdings on WorldChain.

Installation

npm install @holdstation/worldchain-sdk ethers

Setup

import { ethers } from "ethers";
import { TokenProvider } from "@holdstation/worldchain-sdk";

const provider = new ethers.providers.JsonRpcProvider("<YOUR_RPC_URL>");
const tokenProvider = new TokenProvider({ provider });

Get Token Metadata

πŸ“‘ Parameters

Name
Type
Required
Description

tokens

string[] (rest params)

βœ… Yes

One or more token addresses passed as separate arguments (e.g. details(token1, token2, ...))

πŸ“˜ Usage

const WETH = "0x4200000000000000000000000000000000000006";
const USDCe = "0x79A02482A880bCE3F13e09Da970dC34db4CD24d1";

const details = await tokenProvider.details(WETH, USDCe);

console.log(details[WETH]);   // { address, chainId, decimals, symbol, name }
console.log(details[USDCe]);  // { address, chainId, decimals, symbol, name }

Get All Tokens Held by a Wallet

πŸ“‘ Parameters

Name
Type
Required
Description

wallet

string

βœ… Yes

Wallet address to find associated token contracts via Transfer events

πŸ“˜ Usage

const wallet = "0x14a028cC500108307947dca4a1Aa35029FB66CE0";
const tokens = await tokenProvider.tokenOf(wallet);

console.log(tokens); // Array of token contract addresses

Get Balances of Multiple Tokens for One Wallet

πŸ“‘ Parameters

Name
Type
Required
Description

wallet

string

βœ… Yes

Wallet address to get token balances for

tokens

string[]

βœ… Yes

Array of token addresses to check balances

πŸ“˜ Usage

const balances = await tokenProvider.balanceOf({
  wallet: "0x14a028cC500108307947dca4a1Aa35029FB66CE0",
  tokens: [WETH, USDCe, WLD],
});

console.log(balances[WETH]);
console.log(balances[USDCe]);
console.log(balances[WLD]);

Get Balance of a Single Token for Multiple Wallets

πŸ“‘ Parameters

Name
Type
Required
Description

token

string

βœ… Yes

Token address to check balances of

wallets

string[]

βœ… Yes

Array of wallet addresses to fetch balances for the token

πŸ“˜ Usage

const balances = await tokenProvider.balanceOf({
  token: WLD,
  wallets: [
    "0x14a028cC500108307947dca4a1Aa35029FB66CE0",
    "0xc57B9e6f74d393504b7e43C09A6089aEc6f8D6d0"
  ],
});

console.log(balances["0x14a028..."]);
console.log(balances["0xc57B9e6..."]);
πŸ“š
πŸ‘οΈ