DID Resolution

DID resolution is the process of taking a DID string and producing the corresponding DID Document — the public record that contains verification keys, authentication methods, and service endpoints.

Resolution Flow

  1. Parse DID — extract the method name (e.g., sns, pki, web, key)
  2. Route to handler — select the method-specific resolver
  3. Fetch DID Document — the handler queries the appropriate source (on-chain, HTTP, certificate store)
  4. Extract public key — the relying party reads verification methods from the document

DID Document Structure

JSON
 {
  "@context": ["https://www.w3.org/ns/did/v1"],
  "id": "did:sns:attestto.sol",
  "verificationMethod": [{
    "id": "did:sns:attestto.sol#key-1",
    "type": "Ed25519VerificationKey2020",
    "controller": "did:sns:attestto.sol",
    "publicKeyMultibase": "z6Mkf5rGMoatrSj1f..."
  }],
  "authentication": ["did:sns:attestto.sol#key-1"],
  "assertionMethod": ["did:sns:attestto.sol#key-1"]
} 
FieldDescription
idThe DID itself
verificationMethodArray of public keys and their types
authenticationKeys authorized for authentication (login)
assertionMethodKeys authorized for signing claims (credential issuance)

Universal Resolver Pattern

Rather than hard-coding each DID method, a universal resolver dispatches to the correct handler based on the method prefix. Attestto's resolver supports did:sns, did:pki, did:web, did:key, and did:sol.

The wallet-identity-resolver Package

bash
 npm install @attestto/wallet-identity-resolver 

Code Example

TypeScript
 import { resolve } from '@attestto/wallet-identity-resolver'

// Resolve a DID to its DID Document
const doc = await resolve('did:sns:attestto.sol')

// Extract the first public key
const key = doc.verificationMethod[0]
console.log('Key type:', key.type)
console.log('Public key:', key.publicKeyMultibase)

// Check if a specific key is authorized for authentication
const canAuth = doc.authentication.includes(key.id)
console.log('Authorized for auth:', canAuth) 
💡

The resolver can run in both browser and Node.js environments. For production use, point it at your own resolver endpoint to control caching and availability.

Supported Methods

  • did:sns — Solana Name Service (human-readable)
  • did:pki — PKI bridge (X.509 certificates)
  • did:web — DNS-based (hosted DID Documents)
  • did:key — Self-contained (public key in the DID)
  • did:sol — Solana public key