Records API
This document covers the new Records API added to `@onsol/tldparser`. These features provide unified access to domain records across both Solana (SVM) and Monad (EVM) chains.
Records API Documentation
This document covers the new Records API added to @onsol/tldparser. These features provide unified access to domain records across both Solana (SVM) and Monad (EVM) chains.
Overview
The Records API enables developers to:
Fetch individual domain records (Twitter, Discord, avatars, crypto addresses, etc.)
Batch-fetch multiple records efficiently
Resolve avatar URLs with automatic gateway conversion (IPFS, Arweave, NFTs)
Look up main domains for multiple addresses in a single call
Installation
npm/yarn install @onsol/tldparserQuick Start
import { TldParser, Record, NetworkWithRpc } from '@onsol/tldparser';
import { Connection } from '@solana/web3.js';
// Solana
const connection = new Connection('https://api.mainnet-beta.solana.com');
const parser = new TldParser(connection);
// Monad (EVM)
const evmSettings = new NetworkWithRpc('monad', 143, 'https://rpc.monad.xyz');
const evmParser = new TldParser(evmSettings, 'monad');API Reference
getRecord(domainTld, record)
getRecord(domainTld, record)Fetch a single record for a domain.
Parameters:
domainTld
string
Full domain with TLD (e.g., "miester.poor", "miester.mon")
record
Record
The record type to fetch
Returns: Promise<string | null>
Example:
How it works:
SVM (Solana): Derives a sub-account PDA from
Record.Twitter + "." + domain→ fetchesTwitter.miester.poorEVM (Monad): Calls
text(namehash, "com.twitter")on the resolver contract
getRecords(domainTld, records?)
getRecords(domainTld, records?)Batch-fetch multiple records for a domain.
Parameters:
domainTld
string
Full domain with TLD
records
Record[]
Array of record types (optional, defaults to all)
Returns: Promise<RecordResult>
Example:
Performance:
SVM: Uses
getMultipleAccountsInfofor efficient batch fetchingEVM: Uses
Promise.allfor parallel contract calls
getAvatar(domainTld, options?)
getAvatar(domainTld, options?)Fetch and resolve avatar URL to an HTTP-accessible endpoint.
Parameters:
domainTld
string
Full domain with TLD
options
AvatarOptions
Custom gateway URLs (optional)
Returns: Promise<string | null>
Example:
Supported formats:
ipfs://QmXxx
https://ipfs.io/ipfs/QmXxx
QmXxx... (raw CIDv0)
https://ipfs.io/ipfs/QmXxx...
bafyxxx... (raw CIDv1)
https://ipfs.io/ipfs/bafyxxx...
ar://txId
https://arweave.net/txId
arwv://txId
https://arweave.net/txId
https://...
unchanged
data:image/...
unchanged
mpl:<mint>
https://alldomains.id/api/nft/mpl/<mint>
core:<asset>
https://alldomains.id/api/nft/core/<asset>
eip155:1/erc721:0x.../123
https://alldomains.id/api/nft/evm/...
NFT Gateway Requirement:
The NFT gateway endpoint must return the actual image data (not JSON metadata). When implementing a custom NFT gateway, the endpoint should:
Fetch the NFT metadata from the blockchain
Extract the
imagefield from the metadataReturn the raw image bytes with appropriate
Content-Typeheader
The default gateway (https://alldomains.id/api) handles this automatically for:
Metaplex Token Metadata (
mpl:) - Fetches metadata and returns the imageMetaplex Core (
core:) - Fetches Core asset and returns the imageEVM NFTs (
eip155:) - Resolves ERC-721/ERC-1155 tokenURI and returns the image
getMainDomains(addresses)
getMainDomains(addresses)Get main domains for multiple wallet addresses in a single call.
Parameters:
addresses
string[]
Array of wallet addresses
Returns: Promise<(string | null)[]>
Example:
Performance:
SVM: Uses
getMultipleAccountsInfofor batch fetchingEVM: Uses parallel contract calls with
Promise.all
Record Types
Social Records
Record.Twitter
Twitter
com.twitter
Record.Discord
Discord
com.discord
Record.Github
Github
com.github
Record.Reddit
Reddit
com.reddit
Record.Telegram
Telegram
org.telegram
Profile Records
Record.Pic
Pic
avatar
Record.Email
Email
email
Record.Url
Url
url
Crypto Address Records
Record.SOL
SOL
sol
Record.ETH
ETH
eth
Record.BTC
BTC
btc
Record.APTOS
APTOS
aptos
Record.NEAR
NEAR
near
Record.BASE
BASE
base
Record.SUI
SUI
sui
Record.LTC
LTC
ltc
Record.DOGE
DOGE
doge
Record.STACKS
STACKS
stacks
Record.LATTICA
Lattica
lattica
Record.POINT
POINT
point
Storage Records
Record.IPFS
IPFS
ipfs
Record.ARWV
ARWV
arweave
Utility Functions
resolveAvatarUrl(record, options?)
resolveAvatarUrl(record, options?)Standalone utility to resolve avatar URLs. Used internally by getAvatar().
getReverseNode(address) (EVM only)
getReverseNode(address) (EVM only)Compute the reverse node hash for an address (used for reverse resolution).
EVM Chain Configuration
The EVM parser now includes resolver contract addresses:
Architecture Notes
SVM Implementation
Records on Solana are stored as sub-accounts derived from the parent domain:
The getRecords() method uses getMultipleAccountsInfo to batch-fetch all record accounts in a single RPC call.
EVM Implementation
Records on EVM chains are stored in a resolver contract using ENS-compatible text records:
The namehash is computed using the ANS-compatible algorithm (same as ENS but without normalization).
Complete Example
Last updated