Token Indexing & Retrieval
Configuration:
Ordiswap's indexer is configured with retry and rate-limiting capabilities. This is crucial for handling potential network issues and preventing abuse of the API by limiting the number of requests per second.
Token Information Retrieval:
Ordiswap defines functions to retrieve information about tokens from the blockchain indexer.
getToken
: Retrieves detailed information about a specific token using its ticker.
getTokenList
: Retrieves a list of all tokens, converting tickers to uppercase for consistency.
getTokenTickerList
: Retrieves a list of token tickers.
getBtcBalance
: Retrieves the Bitcoin balance for a given address.
Token Balance Retrieval:
Functions to get token balances for a specific token and address.
getTokenBalance
: Retrieves the balance of a specific token for a given address.
getTokenBalanceList
: Retrieves a list of token balances for all tokens associated with a specific address.
Token Information and Indexing:
getTokenInfo
: Retrieves detailed information about a token, including ticker, maximum supply, limit, and decimal points.
brc20_index
: Initiates a continuous process to index new tokens. It queries the blockchain indexer for a list of tokens, checks if each token is already in the collection, fetches detailed information, and inserts new tokens into the collection.
Error Handling:
Ordiswap includes error handling for HTTP requests. If an error occurs, it logs the error and sets an indexerError
flag. Ordiswap checks for a specific error code (-2005) to identify indexer-related issues.
Configuration and Global Variables:
Ordiswap uses configuration variables like INDEXER_URL
, INDEXER_API_KEY
, and FIND_OPTIONS
. These likely represent the endpoint URL for the blockchain indexer, API key for authorization, and find options for DB queries.
System Flow:
Token Retrieval:
Users can retrieve detailed information about individual tokens, lists of tokens, and token tickers.
Balance Retrieval:
Users can obtain token balances for a specific token or a list of balances for all tokens associated with a given address.
Token Indexing:
The continuous process (brc20_index
) fetches the list of tokens from the blockchain indexer, checks and inserts new tokens into the collection, and maintains an error flag (indexerError
).
Last updated