> ## Documentation Index
> Fetch the complete documentation index at: https://sequence-0fb8d9e6-shop-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# useBuyModal

> The useBuyModal hook allows users to purchase an NFT that is listed for sale on the Marketplace. It handles the buying process and transaction execution.

```ts
import { useBuyModal } from "@0xsequence/marketplace-sdk/react";

## Into your React component:

const { show: showBuyModal } = useBuyModal({
	onSuccess(hash) {
		console.log("Buy transaction sent with hash: ", hash);
	},
	onError,
});

const onClickBuy = () => {
	showBuyModal({
		chainId,
		collectionAddress,
		tokenId,
		order,
	});
};

return <button onClick={onClickBuy}>Buy</button>
```

<ResponseField name="useBuyModal">
  <ResponseField name="* params" />

  <Expandable>
    ```ts
    interface useBuyModal {
    	onSuccess?: ({ hash, orderId }: {
    			hash?: Hash;
    			orderId?: string;
    	}) => void;
    	onError?: (error: Error) => void;
    }
    ```
  </Expandable>

  <ResponseField name="* return properties" />

  <Expandable>
    <ResponseField name="show" type="(args: ShowBuyModalArgs) => void">
      ```ts
      interface ShowBuyModalArgs {
      	chainId: string;
      	collectionAddress: Hex;
      	tokenId: string;
      	order: Order;
      }
      ```
    </ResponseField>

    <ResponseField name="close" type="() => void" />
  </Expandable>
</ResponseField>
