🥯Bagel

Domain Resolution

Integrate .bagel domains into your wallet or application

The bagel Domain Resolution API provides a simple way for wallets and applications to resolve .bagel domains to retrieve the corresponding viewing and spending public keys needed for stealth transactions.

API Endpoint

https://api.bagelwallet.fun/resolve/:domain

This API allows any wallet or application to easily integrate support for bagel's privacy features without implementing the full SDK.

Usage

HTTP Request

GET https://api.bagelwallet.fun/resolve/:domain

Where :domain is the bagel domain to resolve (e.g., alice.bagel).

Response Format

A successful response will return JSON with the following structure:

{"stealthAddress":"F93hFRnikRs3MjM7SaEkrKoydEojSu57BYh2JRkjM5Hd",
"domain":"alice"}

The response includes:

  • stealthAddress: The resolved bagel domain's stealthAddress
  • domain: domain name

Error Response

If the domain cannot be resolved, the API will return an error:

{
  "error": "Domain not found",
  "status": "error"
}

Integration Example

Here's how to integrate the bagel Domain Resolution API into your wallet or application:

async function resolvebagelDomain(domain) {
  try {
    const response = await fetch(`https://api.bagelwallet.fun/resolve/${encodeURIComponent(domain)}`);
    if (!response.ok) {
      throw new Error(`Failed to resolve domain: ${response.statusText}`);
    }
    const data = await response.json();
    if (data.status === 'error') {
      throw new Error(data.error);
    }
    // API returns { stealthAddress, domain }
    return {
      domain: data.domain,
      stealthAddress: data.stealthAddress
    };
  } catch (error) {
    console.error('Error resolving bagel domain:', error);
    throw error;
  }
}
 
// Another example usage
// Integration is extremely simple: just resolve the domain and send funds!
// The Bagel API handles all cryptography and registration internally.
 
async function sendTobagelDomain(domain, amount) {
  try {
    // 1. Resolve the domain to get the stealth address
    const recipient = await resolvebagelDomain(domain);
 
    // 2. Send funds to the stealth address using your wallet's send function
    const txId = await sendFunds(recipient.stealthAddress, amount);
 
    return txId;
  } catch (error) {
    console.error('Error sending to bagel domain:', error);
    throw error;
  }
}
 
// That's it! No need to generate keys or register anything the Bagel API does it all for you.

Best Practices

  1. Error Handling: Always implement proper error handling for failed domain resolution
  2. Caching: Consider caching resolved domains for a short period to reduce API calls
  3. User Feedback: Provide clear feedback to users during the resolution process
  4. Rate Limiting: Implement reasonable rate limiting for API calls
  5. Refresh: Make sure you refresh your request for every action to get the latest stealth address so privacy is preserved
  6. Duplicate transactions: Make sure you don't send duplicate transactions to the same stealth address - always refresh for every transaction

CORS Support

The bagel Domain Resolution API supports Cross-Origin Resource Sharing (CORS), allowing it to be used directly from browser-based applications.

API Status

You can check the API status by making a simple request:

GET https://api.bagelwallet.fun/health

A successful response will return:

{
  "status": "ok"
}

By integrating this simple API, your wallet or application can offer bagel's privacy features to users with minimal development effort.

On this page