# Anchor Resolver

The **Anchor Resolver** is the discovery mechanism for Anchor services on Keeta. Think of it like DNS for the internet – just as DNS translates domain names into IP addresses, the Anchor Resolver translates service requirements into anchor endpoints.

### **How It Works**

When you need to find an Anchor service (like an FX provider or Asset Movement service), the Resolver:

1. **Queries the Keeta network** for accounts that provide the service you need
2. **Reads service metadata** from those accounts to understand their capabilities
3. **Matches your requirements** (like currency pairs, supported rails, geographic regions) to available providers
4. **Returns endpoint URLs** and configuration details for compatible services

The Resolver looks up metadata published on-chain by anchor operators. This metadata describes:

* What services they offer (FX, Banking, KYC, Asset Movement, etc.)
* Which currencies, tokens, or assets they support
* Required authentication methods
* API endpoint URLs
* Supported country codes and KYC providers

### **Why It Matters**

The Resolver enables **dynamic service discovery**. Instead of hardcoding anchor URLs in your application, you describe what you need, and the Resolver finds providers that match. This creates a decentralized marketplace where:

* New Anchors can join without client-side updates
* Clients automatically discover the best providers for their needs
* Service availability is stored on-chain
* Geographic and regulatory requirements can be matched

### **Example: Finding an FX Provider**

```typescript
import * as KeetaAnchor from '@keetanetwork/anchor';
import * as KeetaNet from '@keetanetwork/keetanet-client';

async function findFXProvider() {
  const networkAlias = 'test';
	const config = KeetaAnchor.KeetaNet.Client.Config.getDefaultConfig(networkAlias);
	const userClient = KeetaAnchor.KeetaNet.UserClient.fromNetwork(networkAlias, null);
	const networkAddress = userClient.networkAddress;

  // Create a resolver to discover services
	const resolver = new KeetaAnchor.lib.Resolver({
		root: networkAddress,
		client: userClient,
		trustedCAs: []
	});
  
  const USDToken = 'keeta_ap7wtjtyfc4yvt26jstau4n76uqnv4znjnz5pcgpnjsty5vjbxkvmk55yl4f6';
  const KTAToken = 'keeta_anyiff4v34alvumupagmdyosydeq24lc4def5mrpmmyhx3j6vj2uucckeqn52';
  // The resolver automatically finds FX services that can convert
  // between the specified currencies
  const fxServices = await resolver.lookup('fx', {
    inputCurrencyCode: USDToken,
    outputCurrencyCode: KTAToken
  });
  
	if (fxServices) {
		for (const serviceProvider of Object.keys(fxServices)) {
			const resolvedMetadata = await KeetaAnchor.lib.Resolver.Metadata.fullyResolveValuizable(fxServices[serviceProvider]);
			console.log(`Found FX Service: ${serviceProvider}`, util.inspect(resolvedMetadata, { depth: 10, colors: true }));
		}
		// Each service includes operations like getQuote, createExchange, etc.
	}
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeta.com/anchors/overview/anchor-resolver.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
