SOL Pay
  • SOL Pay
  • Quick Start
  • Streams
  • Stake Pools
  • Reference
    • SDK Reference
      • connectNetwork
      • connectWallet
      • sendSolanaLamports
      • sendSolana
      • sendTokens
      • sendTokensDecimal
      • signTransaction
      • broadcastSerializedTransaction
      • streamLamports
      • backupStreamWallet
      • getStreamDetails
      • refillStream
      • pauseStream
      • resumeStream
      • closeStream
      • signMessage
      • getBalance
      • getTokenBalances
      • getAccountInfo
      • getAssociatedTokenAddress
      • getTokenBalance
      • tokens.getData
      • tokens.getTags
      • tokens.getToken
      • tokens.search
      • tokens.getRawUnvalidatedList
      • adapters
      • networks
    • API Reference
      • transaction.php
      • token_transaction.php
      • signature.php
  • Website
  • Source Code
Powered by GitBook
On this page
  • Parameters:
  • Returns:
  • Throws:
  1. Reference
  2. SDK Reference

tokens.search

Searches for an SPL token in the SPL token registry

Previoustokens.getTokenNexttokens.getRawUnvalidatedList

Last updated 3 years ago

(async() => {
    let token_search_1 = await SOLPay.tokens.search("symbol", "USDC"); // {"tokens": [...]}
    let token_search_2 = await SOLPay.tokens.search("symbol", "USDC", "equals"); // {"tokens": [...]}
    let token_search_3 = await SOLPay.tokens.search("symbol", "USDC", "equals", true); // {"tokens": [...]}
})();

Parameters:

  • search: string - what to use to search (address, name, symbol)

  • param: string - the parameter/search term to use to find a token

  • compare_type (optional, default: "equals"): string - how to compare the search for tokens (equals, startsWith, endsWith, includes)

  • skip_validation (optional, default: false): boolean - whether to skip validation on if a token in the SPL token registry is a valid SPL token (true for skipping validation, false for not skipping validation), it is recommended to set this field to true when a large number of tokens are being returned and you want the function to execute quickly

Returns:

object ({"tokens": [...]}) - the list of tokens (see for format)

Throws:

  • SOL Pay SDK Fatal Error: Invalid search ${search}. - an invalid search was used

  • SOL Pay SDK Fatal Error: Invalid compare type ${compare_type}. - an invalid compare type was used

  • SOL Pay SDK Fatal Error: No connection found. Use SOLPay.connectNetwork() to connect to the Solana network. - could not find a connection to the Solana network

  • SOL Pay SDK Fatal Error: Connection did not respond. Use SOLPay.connectNetwork() to connect to the Solana network. - did not receive response from Solana network

https://github.com/solana-labs/token-list/blob/main/src/tokens/solana.tokenlist.json