---
# System prepended metadata

title: DID Discovery plugin

---

# DID Discovery plugin

## Naming

### Plugin name

- QueryDID
- DIDSearch
- DIDDiscovery 👍
- ...

### Method name

- queryDid
- findDid
- discoverDid 👍


## Types

```typescript
export interface IDIDDiscoveryDiscoverDidArgs extends Record<string, any>{
  generic?: string
}

export interface IDIDDiscoverMatch {
  did: string
  metaData: Record<string, any>
}

export interface IDIDDiscoveryProviderResult {
  provider: string
  matches: IDIDDiscoverMatch[]
}

export interface IDIDSearchFindDidResult extends Partial<IDIDDiscoveryDiscoverDidArgs> {
  results: IDIDDiscoveryProviderResult[]
}

export interface IDIDDiscovery extends IPluginMethodMap {
  discoverDid(
    args: IDIDDiscoveryDiscoverDidArgs,
    context: IAgentContext<IDIDManager & IDataStoreORM>,
  ): Promise<IDIDSearchFindDidResult>
  
}
```

## Example

```typescript
const results = await agent.discoverDid({ query: 'alice' })

const results2 = await agent.discoverDid({ 
  query: 'alice',
  options: {
    providers: ['didManagerAlias', 'ens'],
    managed: true
  }
})

const results3 = await agent.discoverDid({ 
  query: 'alice',
  options: {
    providers: ['github'],
    isRegex: false,
    managed: false
  }
})


```

```json=
{
  "query": "alice",
  "results": [
    {
      "provider": "didManagerAlias",
      "matches": [
        {
          "did": "did:web:pulsar.veramo.io:alice",
          "metaData": {
            "alias": "alice"
          }
        },
        {
          "did": "did:web:pulsar.veramo.io:alice-in-wonderland",
          "metaData": {
            "alias": "alice-in-wonderland"
          }
        },

      ]
    },
    {
      "provider": "ens",
      "matches": [
        {
          "did": "did:ethr:0x1234",
          "metaData": {
            "domain": "alice.eth"
          }
        }
      ]
    },    
    {
      "provider": "profileVC",
      "matches": [
        {
          "did": "did:ethr:0x83723",
          "metaData": {
            "verifiableCredential": {
              //...
              "credentialSubject": {
                "id": "did:ethr:0x83723"
                "name": "Alice"
              },
              "proof": "..."
            }
          }
        }
      ]
    }        
  ]
}
```