### Complete D3 API Operations Example Source: https://docs.d3.app/channel-partner-integrations/d3-api/signing-requests-for-wallet-mapping-api A comprehensive JavaScript example demonstrating the setup and execution of multiple D3 API operations, including setting and deleting wallet mappings, setting and unsetting primary names. It utilizes ethers.js for wallet management and signing. ```javascript const { ethers } = require('ethers'); // Configuration const API_KEY = 'your-api-key-here'; const PRIVATE_KEY = 'your-private-key'; // Should be stored securely const wallet = new ethers.Wallet(PRIVATE_KEY); // EIP-712 domain const SignDomain = { name: 'D3 API', version: '1', }; // Type definitions for signatures const SetWeb3RecordTypes = { SetWeb3Record: [ { name: 'domain', type: 'string' }, { name: 'symbol', type: 'string' }, { name: 'address', type: 'string' }, { name: 'signatureExpiresAt', type: 'uint256' }, ], }; const DeleteWeb3RecordTypes = { DeleteWeb3Record: [ { name: 'domain', type: 'string' }, { name: 'symbol', type: 'string' }, { name: 'signatureExpiresAt', type: 'uint256' }, ], }; const SetPrimaryNameTypes = { SetPrimaryName: [ { name: 'name', type: 'string' }, { name: 'signatureExpiresAt', type: 'uint256' }, ], }; const UnsetPrimaryNameTypes = { UnsetPrimaryName: [ { name: 'signatureExpiresAt', type: 'uint256' } ], }; // Example usage async function demonstrateAllOperations() { const domain = "example.com"; const symbol = "ETH"; // 1. Set wallet mapping console.log(`Setting ${symbol} wallet mapping for ${domain}...`); const setResponse = await setWalletMapping(symbol, domain); // Assuming setWalletMapping is defined elsewhere console.log(await setResponse.json()); // 2. Set primary name console.log(`Setting ${domain} as primary name for wallet...`); const setPrimaryResponse = await setPrimaryName(wallet, domain); // Assuming setPrimaryName is defined elsewhere console.log(await setPrimaryResponse.json()); // Wait to demonstrate the operations await new Promise(resolve => setTimeout(resolve, 2000)); // 3. Delete wallet mapping console.log(`Deleting ${symbol} wallet mapping for ${domain}...`); const deleteResponse = await deleteWalletMapping(symbol, domain); // Assuming deleteWalletMapping is defined elsewhere console.log(await deleteResponse.json()); // 4. Unset primary name console.log(`Unsetting primary name for wallet...`); const unsetResponse = await unsetPrimaryName(wallet); console.log(await unsetResponse.json()); } // Implementation of API functions // [Include all the function implementations from above] // Run the demonstration demonstrateAllOperations().catch(console.error); ``` -------------------------------- ### D3 DNS Connect SDK: Basic Usage Example Source: https://docs.d3.app/resolve-d3-names Provides a basic example of using the DNS Connect SDK to resolve a name to a wallet address and perform a reverse resolution. It initializes the SDK and calls the respective methods. ```javascript import { DNSConnect } from '@webinterop/dns-connect'; const dnsConnect = new DNSConnect(); // Resolves `example.core` name on `CORE` blockchain const walletAddress = await dnsConnect.resolve('example.core', 'CORE'); console.log(walletAddress); // Reverse resolves wallet address `0xaaaa` on `CORE` blockchain const domainName = await dnsConnect.reverseResolve('0xaaaa', 'CORE'); console.log(domainName); ``` -------------------------------- ### Install @webinterop/dns-connect via npm Source: https://docs.d3.app/resolve-d3-names Installs the core DNS Connect SDK package using npm. This package provides the modular SDK and the DNS resolution module for basic Web3 wallet address resolution. ```bash npm install @webinterop/dns-connect ``` -------------------------------- ### Install D3 Marketplace Widget with Yarn Source: https://docs.d3.app/channel-partner-integrations/d3-embed Installs the D3 marketplace widget package using the yarn package manager. This is an alternative to npm for installing the widget. ```bash yarn add @d3-inc/marketplace-widget ``` -------------------------------- ### Example: Set Wallet Mapping (JavaScript) Source: https://docs.d3.app/channel-partner-integrations/d3-api/signing-requests-for-wallet-mapping-api Demonstrates how to call the `setWalletMapping` function to associate an 'ETH' wallet with the 'example.d3' domain and log the API response. ```JavaScript // Set "ETH" wallet mapping for domain "example.d3" const response = await setWalletMapping("ETH", "example.d3"); console.log(await response.json()); // Example response: { success: true } ``` -------------------------------- ### Install @webinterop/dns-connect via Yarn Source: https://docs.d3.app/resolve-d3-names Installs the core DNS Connect SDK package using Yarn. This package provides the modular SDK and the DNS resolution module for basic Web3 wallet address resolution. ```bash yarn add @webinterop/dns-connect ``` -------------------------------- ### Install D3 Marketplace Widget with NPM Source: https://docs.d3.app/channel-partner-integrations/d3-embed Installs the D3 marketplace widget package using the npm package manager. This is the first step to integrating the widget into your project. ```bash npm install @d3-inc/marketplace-widget ``` -------------------------------- ### Install @webinterop/dns-connect-ens with NPM Source: https://docs.d3.app/resolve-d3-names Installs the @webinterop/dns-connect-ens module using npm, which is an optional package for adding ENS name resolution support. ```bash npm install @webinterop/dns-connect-ens ``` -------------------------------- ### Install @webinterop/dns-connect-ens with Yarn Source: https://docs.d3.app/resolve-d3-names Installs the @webinterop/dns-connect-ens module using Yarn, providing ENS name resolution capabilities. ```bash yarn add @webinterop/dns-connect-ens ``` -------------------------------- ### Example: Set Primary Name (JavaScript) Source: https://docs.d3.app/channel-partner-integrations/d3-api/signing-requests-for-wallet-mapping-api Demonstrates how to call the `setPrimaryName` function to set 'example.com' as the primary name for the current wallet and log the API response. ```JavaScript // Set "example.com" as the primary name for the wallet const response = await setPrimaryName(wallet, "example.com"); console.log(await response.json()); // Example response: { success: true } ``` -------------------------------- ### D3 DNS Connect SDK: Advanced Configuration Example Source: https://docs.d3.app/resolve-d3-names Illustrates advanced configuration options for the DNS Connect SDK, including customizing DNS resolution module settings, log level, logger implementation, and caching. ```javascript const dnsConnect = new DNSConnect({ // DNS resolution module options (with defaults): dns: { forwarderDomain: 'forwarder.d3.app', // Whether or not DNSSEC verification must be performed by a resolver dnssecVerification: true, // DNS-over-HTTPS resolver is provided by default. It uses dns-json format, which is supported by CloudFlare & Google resolvers. // This could be substituted with different implementations by SDK consumers. resolver: new DNSOverHTTPSResolver({ dnsServer: 'https://cloudflare-dns.com/dns-query', }), }, // Log level for the SDK log messages logLevel: 'info', // "trace" | "info" | "warn" | "error" | "silent" // If needed, custom logger implementation can be provided. // By default, standard console logger is used. logger: , // In-memory cache is used by default to cache resolution result (and intermediate resolution data) // To avoid memory leaks (in server scenarios), or use persistent cache (in browser scenarios), custom caching implementation can be provided. caching: { enabled: true, cacheProvider: , }, }); ``` -------------------------------- ### Example: Delete Wallet Mapping (JavaScript) Source: https://docs.d3.app/channel-partner-integrations/d3-api/signing-requests-for-wallet-mapping-api Demonstrates how to call the `deleteWalletMapping` function to remove the 'ETH' wallet mapping for the 'example.com' domain and log the API response. ```JavaScript // Delete "ETH" wallet mapping for domain "example.com" const response = await deleteWalletMapping("ETH", "example.com"); console.log(await response.json()); // Example response: { success: true } ``` -------------------------------- ### Get Supported Payment Options Source: https://docs.d3.app/channel-partner-integrations/d3-api Retrieves the supported payment options, including contract and token addresses, for specified top-level domains (TLDs). This is done by sending a GET request to the /v1/partner/payment/options endpoint. The response includes chain details, contract and token addresses, symbols, icons, and prices. ```HTTP GET /v1/partner/payment/options HTTP/1.1 Host: Api-Key: YOUR_API_KEY Accept: */* ``` ```JavaScript fetch('/v1/partner/payment/options', { method: 'GET', headers: { 'Api-Key': 'YOUR_API_KEY', 'Accept': '*/*' } }) .then(response => response.json()) .then(data => console.log(data)); ``` ```Python import requests url = "/v1/partner/payment/options" headers = { "Api-Key": "YOUR_API_KEY", "Accept": "*/*" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### D3 Widget Peer Dependencies Source: https://docs.d3.app/channel-partner-integrations/d3-embed Lists the required peer dependencies for the D3 widget, including react-query, react, react-dom, and zustand. These must be installed in your application for the widget to function correctly. ```javascript "@tanstack/react-query": "^5.56.2", "react": "^18.0", "react-dom": "^18.0", "zustand": "^4.5.0" ``` -------------------------------- ### Search for Premium Domains with D3 API Source: https://docs.d3.app/possible-future-use-cases/fractional-ownership-of-names This endpoint allows you to discover high-value domain names to add to a DAO's portfolio. It is a GET request used for searching. ```HTTP GET /v1/partner/search ``` -------------------------------- ### Resolve Name and Reverse Resolve Address using ethers.js (JavaScript) Source: https://docs.d3.app/resolve-d3-names This JavaScript example demonstrates how to interact with the D3 Resolver smart contract using ethers.js. It shows how to resolve a name to an address and reverse resolve an address to a name, ensuring CCIP Read is enabled. ```javascript // RPC url of a network const rpcURL = 'https://rpc.example.com'; // D3 Resolver address on a given network (from docs) const resolverAddress = '0x0123...'; const abi = [ 'function resolve(string name, string network) public view returns (address)', 'function reverseResolve(address addr, string network) public view returns (string)', ]; const provider = new JsonRpcProvider(rpcURL); const resolverContract = new ethers.Contract(resolverAddress, abi, provider); // Resolve a name to address const address = await resolverContract.resolve( 'example.shib', // If empty, name will be resolved for current blockchain '', // Important to explicitly enable CCIP Read { enableCcipRead: true } ); console.log(`Resolved address: ${address}`); // Reverse resolve an address to name const name = await resolverContract.reverseResolve( '0x03456...', '', { enableCcipRead: true, }, ); console.log(`Resolved name: ${name}`); ``` -------------------------------- ### Get Name Recommendations (cURL) Source: https://docs.d3.app/channel-partner-integrations/d3-api This cURL command shows how to request name recommendations based on provided SLDs and TLDs. It requires the SLD parameter and optionally accepts TLDs. An API key is needed for authentication. ```cURL GET /v1/partner/recommendations?sld=example HTTP/1.1 Host: Api-Key: YOUR_API_KEY Accept: */* ``` -------------------------------- ### Delete Wallet Mapping (Python) Source: https://docs.d3.app/channel-partner-integrations/d3-api Illustrates how to delete a wallet mapping using Python's requests library. This example includes setting the API key, headers, and the JSON payload for the DELETE request. ```python import requests import json wallet = 'your_wallet_address' api_key = 'YOUR_API_KEY' url = f"http://your-api-url/v1/reverse-registry/{wallet}" headers = { 'Api-Key': api_key, 'Content-Type': 'application/json', 'accept': '*/*' } payload = { "signature": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "signatureExpiresAt": 1735689600000 } response = requests.delete(url, headers=headers, data=json.dumps(payload)) print(response.status_code) print(response.json()) ``` -------------------------------- ### Get Name Recommendations Response (JSON) Source: https://docs.d3.app/channel-partner-integrations/d3-api This JSON array represents a successful response from the name recommendation API. Each object in the array contains details about a recommended name token, including its SLD, TLD, availability status, pricing, and a click URL. ```JSON [ { "sld": "example", "tld": "com", "status": "available", "eoi": false, "isListed": true, "registrationExpiresAt": "2025-05-15T00:00:00.000Z", "reservationExpiresAt": "2025-05-15T00:00:00.000Z", "registryUsdPrice": "9.99", "registryNativePrice": "1.23456", "listNativePrice": "1.23456", "listUsdPrice": "1.23456", "nativeCurrency": "ETH", "clickUrl": "https://d3.app/search?sld=example&product=example.com&partner=com&utm_source=developer&utm_medium=api", "lockExpiresAt": "2025-05-15T00:00:00.000Z" } ] ``` -------------------------------- ### Example: Remove Primary Name Source: https://docs.d3.app/channel-partner-integrations/d3-api/signing-requests-for-wallet-mapping-api Demonstrates how to call the `unsetPrimaryName` function and log the API response. It shows a practical use case for removing a wallet's primary name. ```javascript // Remove the primary name for the wallet const response = await unsetPrimaryName(wallet); console.log(await response.json()); // Example response: { success: true } ``` -------------------------------- ### Customizing ENSModule with Viem Source: https://docs.d3.app/resolve-d3-names Shows how to customize the ENSModule by providing specific Viem chain and transport configurations for custom network integration, such as testnets or private deployments. ```javascript import { DNSConnect } from '@webinterop/dns-connect'; import { ENSModule } from '@webinterop/dns-connect-ens'; import { http } from 'viem'; import { mainnet } from 'viem/chains'; const dnsConnect = new DNSConnect({ modules: [ new ENSModule({ // Be default, `viem` Ethereum Mainnet network is used. // Custom network can be provided for testnet or private deployments. chain: mainnet, // By default, HTTP transport used transport: http(), }), ], }); ``` -------------------------------- ### Initialize D3Widget with Callback for Purchases Source: https://docs.d3.app/channel-partner-integrations/d3-embed Initializes the D3 widget using the callback method for purchase transactions. It requires specifying the app name, API key, and providing a callback function `onPurchaseInit` to handle the transaction logic. The `walletAddress` prop ensures the correct wallet is used. ```javascript import { D3Widget } from '@d3-inc/marketplace-widget'; ``` -------------------------------- ### Delete Wallet Mapping (cURL) Source: https://docs.d3.app/channel-partner-integrations/d3-api Provides a cURL command to delete a wallet mapping. This example includes the necessary headers, endpoint, and JSON payload for the request. ```bash curl -X DELETE \ 'http://your-api-url/v1/reverse-registry/{wallet}' \ -H 'accept: */*' \ -H 'Api-Key: YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "signature": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", "signatureExpiresAt": 1735689600000 }' ``` -------------------------------- ### Basic ENS Resolution with DNSConnect Source: https://docs.d3.app/resolve-d3-names Demonstrates basic usage of the ENSModule with DNSConnect to resolve an ENS name ('test.eth') to an Ethereum wallet address. It requires importing DNSConnect and ENSModule. ```javascript import { DNSConnect } from '@webinterop/dns-connect'; import { ENSModule } from '@webinterop/dns-connect-ens'; const dnsConnect = new DNSConnect({ modules: [new ENSModule()] }); const walletAddress = await d3Connect.resolve('test.eth', 'ETH'); console.log(walletAddress); ``` -------------------------------- ### Get Name Tokens for Wallet Address Source: https://docs.d3.app/channel-partner-integrations/d3-api Retrieves registered name tokens associated with a given wallet address. Requires an API key for authorization. Supports filtering by address type and pagination. ```HTTP GET /v1/partner/tokens/{addressType}/{address} HTTP/1.1 Host: Api-Key: YOUR_API_KEY Accept: */* ``` -------------------------------- ### D3 DNS Connect SDK: Resolve and Reverse Resolve Methods Source: https://docs.d3.app/resolve-d3-names Demonstrates the core `resolve` and `reverseResolve` methods of the DNS Connect SDK. `resolve` maps a name to an address, while `reverseResolve` maps an address back to a name on a specified network. ```typescript /** * Resolves a name to an address. * @param name - The name to resolve. * @param network - The network to resolve the name on. * @returns The resolved address. */ async resolve(name: string, network: string): Promise /** * Resolves an address to a name. * @param address - The address to resolve. * @param network - The network to resolve the address on. * @returns The resolved name. */ async reverseResolve(address: string, network: string): Promise ``` -------------------------------- ### D3 Widget Purchase Flow Props and Callback Signature Source: https://docs.d3.app/channel-partner-integrations/d3-embed Details the essential props for the D3 widget's purchase flow, including `walletAddress` for transaction initiation and `onPurchaseInit`. The `onPurchaseInit` callback signature is provided, along with type definitions for `CheckoutCallback` and `PaymentOption` used within the callback. ```typescript onPurchaseInit: ({ transactionVoucher, handleOnError, handleOnSuccess }) => Promise // the widget exports the types for these arguments import type { CheckoutCallback, PaymentOption } from '@d3-inc/marketplace-widget'; // than you can use these types in the callback (if your project uses typescript) // below is the detailed overview of the transactionVoucher parameter type PaymentOption = { tokenAddress: string; contractAddress: string; symbol: string; icon: string; price: number; addressType: WalletAddress; chainId: string; // this is important to check the chain, where this payment option is available on }; type CheckoutOrderRequestResponse = { voucher: { paymentId: string; amount: string; token: `0x${string}` | string; buyer: `0x${string}` | string; voucherExpiration: number; orderId: string; names: { label: string; tld: string; registry: `0x${string}` | string; expirationTime: number; owner: `0x${string}` | string; renewal: false; }[]; }; signature: `0x${string}` | string; }; type CheckoutCallback = CheckoutOrderRequestResponse & { selectedPaymentToken: PaymentOption; }; ``` -------------------------------- ### D3 Widget onPurchaseInit Callback Source: https://docs.d3.app/channel-partner-integrations/d3-embed This snippet demonstrates the structure of the `onPurchaseInit` callback function for the D3 Widget. It includes the expected parameters `transactionVoucher`, `handleOnError`, and `handleOnSuccess`, along with TypeScript type definitions for these arguments and related data structures like `PaymentOption` and `CheckoutCallback`. ```TypeScript onPurchaseInit: ({ transactionVoucher, handleOnError, handleOnSuccess }) => Promise ``` ```TypeScript import type { CheckoutCallback, PaymentOption } from '@d3-inc/marketplace-widget'; ``` ```TypeScript type PaymentOption = { tokenAddress: string; contractAddress: string; symbol: string; icon: string; price: number; addressType: WalletAddress; chainId: string; // this is important to check the chain, where this payment option is available on }; ``` ```TypeScript type CheckoutOrderRequestResponse = { voucher: { paymentId: string; amount: string; token: `0x${string}` | string; buyer: `0x${string}` | string; voucherExpiration: number; orderId: string; names: { label: string; tld: string; registry: `0x${string}` | string; expirationTime: number; owner: `0x${string}` | string; renewal: false; }[]; }; signature: `0x${string}` | string; }; ``` ```TypeScript type CheckoutCallback = CheckoutOrderRequestResponse & { selectedPaymentToken: PaymentOption; }; ``` -------------------------------- ### D3 Widget Wallet Configuration Options Source: https://docs.d3.app/channel-partner-integrations/d3-embed Provides type definitions for wallet configuration options in the D3 widget, including WalletConnect, Coinbase, and MetaMask parameters. These types are reused from `@wagmi/connectors`. ```typescript walletConfig: { walletConnectKey: string; walletConnect?: WalletConnectParameters; coinbase?: CoinbaseWalletParameters; metaMask?: MetaMaskParameters; } //Above types are being re-used from the @wagmi/connectors. You can check more details here ``` -------------------------------- ### Using a Custom Resolution Module with DNSConnect Source: https://docs.d3.app/resolve-d3-names Demonstrates how to integrate a custom resolution module (e.g., CustomModule) into the DNSConnect instance by passing it within the modules array in the constructor options. ```javascript import { DNSConnect } from '@webinterop/dns-connect'; const dnsConnect = new DNSConnect({ modules: [new CustomModule()] }); const walletAddress = await dnsConnect.resolve('test.custom', 'ETH'); console.log(walletAddress); ``` -------------------------------- ### Get Name Token Metadata by Token ID Source: https://docs.d3.app/channel-partner-integrations/d3-api Retrieves the metadata for a specific name token using its unique token ID. This endpoint requires the chain ID, contract address, and the token ID as path parameters. It is secured with an API key. ```cURL GET /v1/partner/token/{chainId}/{contractAddress}/{tokenId} HTTP/1.1 Host: Api-Key: YOUR_API_KEY Accept: */* ``` ```JavaScript fetch('/v1/partner/token/{chainId}/{contractAddress}/{tokenId}', { method: 'GET', headers: { 'Api-Key': 'YOUR_API_KEY', 'Accept': '*/*' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```Python import requests url = "/v1/partner/token/{chainId}/{contractAddress}/{tokenId}" headers = { "Api-Key": "YOUR_API_KEY", "Accept": "*/*" } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Create Partner Order for Name Token Purchase Source: https://docs.d3.app/channel-partner-integrations/d3-api Creates a new order for name token purchase. The API call requires an API key for authorization and a JSON payload containing payment options and name details. The response includes a payment voucher and order details. ```HTTP POST /v1/partner/order HTTP/1.1 Host: Api-Key: YOUR_API_KEY Content-Type: application/json Accept: */* Content-Length: 569 { "paymentOptions": { "contractAddress": "0x46A7bEA3dBb87522834c8b24FA14D051893deE8a", "tokenAddress": "0x0000000000000000000000000000000000000000", "buyerAddress": "0x65d90DBa570408f8D512c91556d8E405acd99EE2" }, "names": [ { "sld": "example1", "tld": "shib", "autoRenew": false, "domainLength": 1 } ], "registrantContact": { "firstName": "text", "lastName": "text", "organization": "Example Inc", "email": "john.doe@example.com", "phone": "234567890", "phoneCountryCode": "+1", "fax": "234567890", "faxCountryCode": "+1", "street": "text", "city": "text", "state": "text", "postalCode": "text", "countryCode": "text" } } ``` ```cURL curl -X POST \ http://your-api-domain.com/v1/partner/order \ -H 'Api-Key: YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -H 'Accept: */*' \ -d '{ "paymentOptions": { "contractAddress": "0x46A7bEA3dBb87522834c8b24FA14D051893deE8a", "tokenAddress": "0x0000000000000000000000000000000000000000", "buyerAddress": "0x65d90DBa570408f8D512c91556d8E405acd99EE2" }, "names": [ { "sld": "example1", "tld": "shib", "autoRenew": false, "domainLength": 1 } ], "registrantContact": { "firstName": "text", "lastName": "text", "organization": "Example Inc", "email": "john.doe@example.com", "phone": "234567890", "phoneCountryCode": "+1", "fax": "234567890", "faxCountryCode": "+1", "street": "text", "city": "text", "state": "text", "postalCode": "text", "countryCode": "text" } }' ``` ```JavaScript const fetch = require('node-fetch'); const apiKey = 'YOUR_API_KEY'; const apiUrl = 'http://your-api-domain.com/v1/partner/order'; const orderData = { "paymentOptions": { "contractAddress": "0x46A7bEA3dBb87522834c8b24FA14D051893deE8a", "tokenAddress": "0x0000000000000000000000000000000000000000", "buyerAddress": "0x65d90DBa570408f8D512c91556d8E405acd99EE2" }, "names": [ { "sld": "example1", "tld": "shib", "autoRenew": false, "domainLength": 1 } ], "registrantContact": { "firstName": "text", "lastName": "text", "organization": "Example Inc", "email": "john.doe@example.com", "phone": "234567890", "phoneCountryCode": "+1", "fax": "234567890", "faxCountryCode": "+1", "street": "text", "city": "text", "state": "text", "postalCode": "text", "countryCode": "text" } }; fetch(apiUrl, { method: 'POST', headers: { 'Api-Key': apiKey, 'Content-Type': 'application/json', 'Accept': '*/*' }, body: JSON.stringify(orderData) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```Python import requests import json api_key = 'YOUR_API_KEY' api_url = 'http://your-api-domain.com/v1/partner/order' order_data = { "paymentOptions": { "contractAddress": "0x46A7bEA3dBb87522834c8b24FA14D051893deE8a", "tokenAddress": "0x0000000000000000000000000000000000000000", "buyerAddress": "0x65d90DBa570408f8D512c91556d8E405acd99EE2" }, "names": [ { "sld": "example1", "tld": "shib", "autoRenew": false, "domainLength": 1 } ], "registrantContact": { "firstName": "text", "lastName": "text", "organization": "Example Inc", "email": "john.doe@example.com", "phone": "234567890", "phoneCountryCode": "+1", "fax": "234567890", "faxCountryCode": "+1", "street": "text", "city": "text", "state": "text", "postalCode": "text", "countryCode": "text" } } headers = { 'Api-Key': api_key, 'Content-Type': 'application/json', 'Accept': '*/*' } response = requests.post(api_url, headers=headers, data=json.dumps(order_data)) print(response.json()) ``` -------------------------------- ### Embed D3 Widget with Wallet Connection Source: https://docs.d3.app/channel-partner-integrations/d3-embed Demonstrates how to embed the D3 widget in a React application, including built-in wallet management using wagmi and viem. It shows how to configure appearance, API key, TLDs, API endpoint, and WalletConnect. ```jsx ``` -------------------------------- ### Handle Crypto Checkout Transaction Callback Source: https://docs.d3.app/channel-partner-integrations/d3-embed Defines the structure and implementation for the `handleCryptoCheckout` function, which is called by the D3 widget to initiate a crypto transaction. It receives `transactionVoucher`, `handleOnError`, and `handleOnSuccess` as parameters to manage the transaction lifecycle. ```typescript import type { CheckoutCallback, PaymentOption } from '@d3-inc/marketplace-widget'; type PurchaseTransactionProps = { handleOnSuccess: (receipt: TransactionReceipt | undefined) => void; handleOnError: (error: BaseError | string) => void; transactionVoucher: CheckoutCallback; }; async function handleCryptoCheckout({ transactionVoucher, handleOnError, handleOnSuccess, }: HandleCryptoCheckoutProps) { // Your logic related to the crypto transaction goes here // Please check the detailed types of CheckoutCallback } ``` -------------------------------- ### Get Name Token Metadata Source: https://docs.d3.app/channel-partner-integrations/d3-api Retrieves metadata and registration status for a given name token using its second-level domain (SLD) and top-level domain (TLD). Requires an API key for authorization. The response includes details like status, registration dates, owner, and token ID. ```HTTP GET /v1/partner/token/{sld}/{tld} HTTP/1.1 Host: Api-Key: YOUR_API_KEY Accept: */* ``` ```cURL curl -X GET "http://your-api-domain.com/v1/partner/token/example/com" -H "Api-Key: YOUR_API_KEY" -H "Accept: */*" ``` ```JavaScript const fetch = require('node-fetch'); const apiKey = 'YOUR_API_KEY'; const sld = 'example'; const tld = 'com'; const apiUrl = `http://your-api-domain.com/v1/partner/token/${sld}/${tld}`; fetch(apiUrl, { method: 'GET', headers: { 'Api-Key': apiKey, 'Accept': '*/*' } }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```Python import requests api_key = 'YOUR_API_KEY' sld = 'example' tld = 'com' api_url = f'http://your-api-domain.com/v1/partner/token/{sld}/{tld}' headers = { 'Api-Key': api_key, 'Accept': '*/*' } response = requests.get(api_url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Name Token Metadata by Multiple Token IDs Source: https://docs.d3.app/channel-partner-integrations/d3-api Fetches metadata for multiple name tokens concurrently by providing a list of their token IDs. This POST endpoint requires the chain ID, contract address, and a JSON body containing the token IDs. Authorization is handled via an API key. ```cURL POST /v1/partner/tokens/{chainId}/{contractAddress} HTTP/1.1 Host: Api-Key: YOUR_API_KEY Content-Type: application/json Accept: */* Content-Length: 21 { "tokenIds": [ "text" ] } ``` ```JavaScript fetch('/v1/partner/tokens/{chainId}/{contractAddress}', { method: 'POST', headers: { 'Api-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json', 'Accept': '*/*' }, body: JSON.stringify({ "tokenIds": ["text"] }) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` ```Python import requests import json url = "/v1/partner/tokens/{chainId}/{contractAddress}" headers = { "Api-Key": "YOUR_API_KEY", "Content-Type": "application/json", "Accept": "*/*" } data = { "tokenIds": ["text"] } response = requests.post(url, headers=headers, data=json.dumps(data)) print(response.json()) ``` -------------------------------- ### Search for Premium Domains with D3 API Source: https://docs.d3.app/possible-future-use-cases/liquidity-pool-for-trading-strategies This API endpoint allows you to discover high-value domain names to add to a DAO's portfolio. It is a key part of identifying potential trading assets. ```HTTP GET /v1/partner/search ``` -------------------------------- ### Mint Names on Primary Sale with D3 API Source: https://docs.d3.app/possible-future-use-cases/liquidity-pool-for-trading-strategies This API endpoint allows for the minting of domain names on their primary sale. It is used for acquiring new domains directly. ```HTTP POST /v1/partner/mint ``` -------------------------------- ### Purchase Domains Using Pooled Liquidity with D3 API Source: https://docs.d3.app/possible-future-use-cases/liquidity-pool-for-trading-strategies This API endpoint enables the use of pooled liquidity to make domain purchases. It facilitates the execution of trading strategies by acquiring domain names. ```HTTP POST /v1/partner/purchase ``` -------------------------------- ### Resolver Smart Contract Methods (Solidity) Source: https://docs.d3.app/resolve-d3-names These Solidity functions are available in the Resolver smart contracts for handling forward and reverse name resolution via CCIP Read. The `resolve` function maps a name to an address, and `reverseResolve` maps an address to a name. ```solidity /** * @notice Resolve a name to an address using CCIP Read * @param name Name to resolve. * @param network (Optional) Network (blockchain) to resolve the name for. If not provided, defaults to current network. * @return resolvedAddress Resolved address. */ function resolve( string name, string network ) external view returns (address); /** * @notice Reverse resolve an address to a name using CCIP Read * @param addr Address to resolve. * @param network (Optional) Network (blockchain) to use. If not provided, defaults to current network. * @return name Resolved name. */ function reverseResolve( address addr, string network ) external view returns (string) ``` -------------------------------- ### Import D3 Widget Styles Source: https://docs.d3.app/channel-partner-integrations/d3-embed Imports the necessary CSS styles for the D3 widget. This should be done at the root of your application to ensure the widget's styles are applied globally. ```javascript import '@d3-inc/marketplace-widget/styles.css'; ``` -------------------------------- ### Implementing a Custom DNS Resolution Module Source: https://docs.d3.app/resolve-d3-names Provides an interface and class structure for creating custom DNS resolution modules by implementing the DNSConnectModule interface, including methods for resolving and reverse-resolving names. ```typescript export interface CustomModuleOptions { // Module options here } export class CustomModule implements DNSConnectModule { // Name is used for logging purposes name = 'MyModuleName'; constructor(options?: CustomModuleOptions) { // Initialize your module } async resolve(name: string, network: string): Promise { // Perform resolution of the provided name using custom logic. // If name cannot be resolved by this module, return `undefined`. return { // Return resolved wallet address (MUST not be empty) address: resolvedAddress, // Return TTL for resolved address (in seconds) // 0 can be returned to disable caching for this name ttl: 30, }; } async reverseResolve(address: string, network: string): Promise { // Perform reverse resolution of the provided address using custom logic. // If address cannot be reverse resolved by this module, return `undefined`. return { // Return reverse resolved name (MUST not be empty) name: resolvedName, // Return TTL for resolved address (in seconds) // 0 can be returned to disable caching for this name ttl: 30, }; } ``` -------------------------------- ### Integrate Name Token Sales with D3 API Source: https://docs.d3.app/index Integrate Name Token sales directly into your platform using D3's public APIs. This allows users to search, purchase, and mint Name Tokens while managing the experience within your application. ```Documentation Integrate Name Token Sales Add Name Token sales directly into your platform. Use our public APIs to allow users to search, purchase, and mint Name Tokens while managing the experience within your app. ``` -------------------------------- ### Search Name Tokens (cURL) Source: https://docs.d3.app/channel-partner-integrations/d3-api This cURL command demonstrates how to search for name tokens, checking their availability and pricing. It requires a second-level domain (SLD) and optionally accepts a top-level domain (TLD). The API key is necessary for authorization. ```cURL GET /v1/partner/search?sld=example HTTP/1.1 Host: Api-Key: YOUR_API_KEY Accept: */* ``` -------------------------------- ### D3 API Signing Domain and Record Types (JavaScript) Source: https://docs.d3.app/channel-partner-integrations/d3-api/signing-requests-for-wallet-mapping-api Defines the EIP-712 domain and types for setting a web3 record (wallet mapping) in the D3 API. These constants are used in conjunction with the wallet's signing function. ```JavaScript const SignDomain = { name: 'D3 API', version: '1', }; const SetWeb3RecordTypes = { SetWeb3Record: [ { name: 'domain', type: 'string' }, { name: 'symbol', type: 'string' }, { name: 'address', type: 'string' }, { name: 'signatureExpiresAt', type: 'uint256' }, ], }; ``` -------------------------------- ### Purchase Domains as a Group with D3 API Source: https://docs.d3.app/possible-future-use-cases/fractional-ownership-of-names This endpoint facilitates the purchase of domains using pooled liquidity within a DAO. It is a POST request for making purchases. ```HTTP POST /v1/partner/purchase ``` -------------------------------- ### Purchase Names API Endpoint Source: https://docs.d3.app/use-cases/sell-name-tokens-to-users-in-your-app This API endpoint facilitates the purchase of name tokens. It is a key component of the D3 Sales APIs for integrating domain sales into your application. ```HTTP POST /v1/partner/purchase ``` -------------------------------- ### D3 Link Integration (HTML) Source: https://docs.d3.app/channel-partner-integrations/d3-link This snippet shows how to create an HTML anchor tag that redirects users to a D3 page with affiliate tracking parameters. It requires a valid affiliate ID to function correctly. ```HTML Shop Now ```