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/tldparser

Quick 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)

Fetch a single record for a domain.

Parameters:

Parameter
Type
Description

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 → fetches Twitter.miester.poor

  • EVM (Monad): Calls text(namehash, "com.twitter") on the resolver contract


getRecords(domainTld, records?)

Batch-fetch multiple records for a domain.

Parameters:

Parameter
Type
Description

domainTld

string

Full domain with TLD

records

Record[]

Array of record types (optional, defaults to all)

Returns: Promise<RecordResult>

Example:

Performance:

  • SVM: Uses getMultipleAccountsInfo for efficient batch fetching

  • EVM: Uses Promise.all for parallel contract calls


getAvatar(domainTld, options?)

Fetch and resolve avatar URL to an HTTP-accessible endpoint.

Parameters:

Parameter
Type
Description

domainTld

string

Full domain with TLD

options

AvatarOptions

Custom gateway URLs (optional)

Returns: Promise<string | null>

Example:

Supported formats:

Input Format
Output

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:

  1. Fetch the NFT metadata from the blockchain

  2. Extract the image field from the metadata

  3. Return the raw image bytes with appropriate Content-Type header

The default gateway (https://alldomains.id/api) handles this automatically for:

  • Metaplex Token Metadata (mpl:) - Fetches metadata and returns the image

  • Metaplex Core (core:) - Fetches Core asset and returns the image

  • EVM NFTs (eip155:) - Resolves ERC-721/ERC-1155 tokenURI and returns the image


Record Types

Social Records

Record
SVM Key
EVM Key

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
SVM Key
EVM Key

Record.Pic

Pic

avatar

Record.Email

Email

email

Record.Url

Url

url

Crypto Address Records

Record
SVM Key
EVM Key

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
SVM Key
EVM Key

Record.IPFS

IPFS

ipfs

Record.ARWV

ARWV

arweave


Utility Functions

resolveAvatarUrl(record, options?)

Standalone utility to resolve avatar URLs. Used internally by getAvatar().

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