SDK Reference

Complete reference for all methods available in the Self SDK.

Name Resolution

resolveName

  1. Resolve a Self name to its default address i.e owner of name (NFT).

    async function resolveName(name: string): Promise<string>
    
    // Example
    const address = await sdk.resolveName('ricomaverick')
    // Returns: "0x383D8ee00c3Ea31dd4eb6e5eCf649Bc9C08D8e31"
    

Metadata

resolveCrossChain

  1. Resolves a Self name to its owner's address (BSC by default).

    async function resolveCrossChain(
      name: string,
      chain: ChainIntegrationKey
    ): Promise<string>
    
    // Example
    const ethAddress = await sdk.resolveCrossChain('ricomaverick', 'eth')
    const btcAddress = await sdk.resolveCrossChain('ricomaverick', 'btc')
    

resolveMetadata

  1. Retrieves complete metadata for a Self name.

    async function resolveMetadata(name: string): Promise<Metadata>
    
    // Example
    const metadata = await sdk.resolveMetadata('ricomaverick')
    

Utility Methods

hashName

  1. Generates the hash of a Self name.

    function hashName(name: string): string
    
    // Example
    const hash = sdk.hashName('ricomaverick')
    

isValidName

  1. Checks if a name follows the valid format rules.

    function isValidName(name: string): boolean
    
    // Example
    const isValid = sdk.isValidName('ricomaverick')
    

Types

ResolverOptions

  1. Configuration options for the SDK.

    interface ResolverOptions {
      /**
       * Custom RPC URL for the blockchain provider
       * @default "https://bsc-dataseed1.binance.org/"
       */
      rpcUrl?: string
    
      /**
       * Custom IPFS gateway URL
       * @default "https://ipfs.io/ipfs/"
       */
    
      ipfsGateway?: string
    }
    

Metadata

  1. Structure of name metadata.

    interface Metadata {
      name: string
      description: string
      image: string
      email?: string
      foreignAddresses: {
        [key in ChainIntegrationKey]?: {
          address: string
        }
      }
    }
    

ChainIntegrationKey

  1. Integration keys for supported blockchain.

    type ChainIntegrationKey =
      | 'eth'
      | 'bsc'
      | 'btc'
      | 'ltc'
      | 'xmr'
      | 'trx'
      | 'nim'
      | 'ada'
      | 'sol'
      | 'xlm'
      | 'xrp'
      | 'eos'
      | 'klv'
      | 'dot'
      | 'polygon'
      | 'avax'
      | 'arb'
      | 'bnb'
      | 'strk'
      | 'email'