# Unsolicited Offers

Unsolicited offers allow buyers to propose a purchase price for a domain not listed for sale. The domain owner can then accept or ignore the offer.

### Struct

```rust
pub struct Offer {
    /// Tag
    pub tag: Tag,
    /// Nonce
    pub nonce: u8,
    /// Name account of the offer
    pub name_account: Pubkey,
    /// Offer owner
    pub owner: Pubkey,
    /// Quote token used for offer
    pub quote_mint: Pubkey,
    /// Amount of the offer
    pub offer_amount: u64,
    /// Escrow account key
    pub escrow: Pubkey,
}
```

### Make Offer

<pre class="language-typescript"><code class="lang-typescript">import { NAME_OFFERS_ID, makeOffer } from "@bonfida/name-offers";
import { getDomainKeySync } from "@bonfida/spl-name-service";
<strong>
</strong><strong>const mint = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"); // USDC mint
</strong>const amount = 1 * 1e6; // Amount with decimals, here 1 USDC
const { pubkey: domainKey } = getDomainKeySync("something.sol"); // Domain public key
const owner = new PublicKey("..."); // Owner of the unsolicited offer
const tokenSource = new PublicKey("..."); // Token source used to place the offer.

const ix = await makeOffer(
  amount,
  domainKey,
  owner,
  mint,
  tokenSource,
  NAME_OFFERS_ID
);

// ... sign and send instruction
</code></pre>

### Accept Offer

```typescript
import { 
NAME_OFFERS_ID, 
getOffersForName, 
acceptOffer 
} from "@bonfida/name-offers";
import { getDomainKeySync } from "@bonfida/spl-name-service";

const domainOwner = new PublicKey("..."); // Current domain owner
const { pubkey: domainKey } = getDomainKeySync("something.sol"); // Domain public key
const offerEscrow = new PublicKey("..."); // PDA used to store the funds of the offer, the address is written in the state
const destination = new PublicKey("..."); // The token account used to receive the funds from the escrow
const referrer: PublicKey | undefined = undefined; // Optional referrer

// Use a util function from the SDK to get offers by domain name, by domain owner, etc.
const offers = await getOffersForName(connection, "something.sol");

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

const ix = await acceptOffer(
  connection,
  NAME_OFFERS_ID,
  offerKey,
  offerOwner,
  publicKey,
  domainKey,
  offerEscrow,
  destination,
  referrer
);

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

### Cancel Offer

```typescript
import { 
NAME_OFFERS_ID, 
cancelOffer 
} from "@bonfida/name-offers";
import { getDomainKeySync } from "@bonfida/spl-name-service";
import { getAssociatedTokenAddress } from "@solana/spl-token";

// Offer token mint is the mint address of the token the offer was made in.
const tokenDestination = getAssociatedTokenAddress(offerTokenMint, offerOwner);

// See acceptOffer example above for offerKey description
const ix = await cancelOffer(domainOwner, tokenDestination, offerKey, NAME_OFFERS_ID)

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


---

# 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.sns.id/dev/sns-sdk/sales-and-listings/unsolicited-offers.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.
