> For the complete documentation index, see [llms.txt](https://docs.sns.id/dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sns.id/dev/sns-sdk/sales-and-listings/category-offers.md).

# Category Offers

Category Offers allow buyers to bid on an entire domain category. Sellers can accept these offers, selling domains within the specified category.

### Struct

```rust
pub struct CategoryOffer {
    // Account tag
    pub tag: Tag,
    // The PDA nonce
    pub nonce: u8,
    // The total number of domains requested
    pub nb_domains: u64,
    // The SOL price per domain
    pub sol_price: u64,
    // The category of the offer
    pub category: Pubkey,
    // The owner of the offer
    pub owner: Pubkey,
    // Timestamp at which the offer was created
    pub created_at: u64,
}
```

### Make Category Offer

The creation of a category offer is managed by the `makeCategoryOffer` function, which specifies the number of domains, the SOL price per domain, and the category.

```typescript
import { CATEGORIES } from "@bonfida/sns-categories"; // Map of current categories
import { NAME_OFFERS_ID, makeCategoryOffer } from "@bonfida/name-offers";

const amount = 10 * LAMPORTS_PER_SOL; // Amount of the offer in lamports here 10 SOL
const nbDomains = 10; // Number of domains the buyer wants to buy
const buyer = new PublicKey("...");

// Filter CATEGORIES to find the categoryKey which is the Public key of the category.
const categoryKey = [...CATEGORIES].find(
  ([, value]) => value === "999-club"
)?.[0];

const ix = await makeCategoryOffer(
  amount,
  nbDomains,
  categoryKey,
  NAME_OFFERS_ID,
  buyer
);

// ... sign and send instruction
```

### Take (Accept) Category Offer

Taking/accepting a category offer is facilitated through the `takeCategoryOffer` function, allowing sellers to sell domains within the category at the specified price.

```typescript
import { CategoryMember } from "@bonfida/sns-categories"; // Map of current categories
import { getDomainKeySync } from "@bonfida/spl-name-service";
import { 
NAME_OFFERS_ID, 
getCategoryOffer, 
takeCategoryOffer 
} from "@bonfida/name-offers";
import { getDomainKeySync } from "@bonfida/spl-name-service";
const { pubkey: domainKey } = getDomainKeySync("999.sol"); // Domain public key
const memberKey = CategoryMember.findKey("999", categoryKey); // Membership of the domain to the category
const seller = new PublicKey("..."); // Seller of the domain here 999.sol
const referrer: PublicKey | undefined = undefined; // Optional referrer

// Use a util function to get category offers by category, category offers for a specific owner, etc.
const categoryOffers = await getCategoryOffer(connection, categoryKey);

// This example arbitrarily selects the first category offer in the list. Filter offers based on your needs.
const categoryOfferKey = categoryOffers[0].pubkey;

const ix = await takeCategoryOffer(
  connection,
  NAME_OFFERS_ID,
  categoryOfferKey,
  domainKey,
  memberKey,
  seller,
  referrer
);

// ... sign and send instruction
```
