# Code Integration

First, c[reate a `<div>` tag where you want to locate the widget:](#user-content-fn-1)[^1]&#x20;

```html
<div id="widget"></div>
```

To initialize the widget add this to the script tag at the bottom of the`<body>` tag:

```html
<script>
  const configuration = {
    paletteOverrides: {
      paper: "#1A1F23",
      secondary: "#2B363B",
      "text-primary": "#fff",
      "text-secondary": "#C5C9C9",
      primary: "#38D9C0",
      "text-primaryButton": "#fff",
      paperSecondaryBackground: "undefined",
    },
    widgetType: "nft",
  };

  const script = document.createElement("script");
  script.src =
    "https://bofdevstorage.blob.core.windows.net/blobcontainer/crypto_trading_widget_sdk/index.js";
  document.head.appendChild(script);
  script.onload = () => {
    window.CryptoTradingWidget.initNftWidget("widget", configuration);
  };
</script>
```

If you'd like to place an 'Open order' button to trigger the widget you can add an 'onClick' event:

```html
<button id="orderButton">Open order</button>
```

Finally, place the following script in the \<body> with and replace the `orderHash` with your copied listing ID:

```html
<script>
  const button = document.getElementById("orderButton");
  const openOrder = () => {
    const orderHash =
      "0xa35d92dad8c08d24b46ab0a8204768d4a5acbeb4dee21a04fd2616c7d0a5dfac";
    const chainId = 137;
    window.CryptoTradingWidget.openOrder(orderHash, chainId);
  };

  button.onclick = openOrder;
</script>
```

This is the full code :)

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Widget Demo</title>
  </head>
  <body>
    <div id="widget"></div>

    <script>
      const configuration = {
        paletteOverrides: {
          paper: "#1A1F23",
          secondary: "#2B363B",
          "text-primary": "#fff",
          "text-secondary": "#C5C9C9",
          primary: "#38D9C0",
          "text-primaryButton": "#fff",
          paperSecondaryBackground: "undefined",
        },
        widgetType: "nft",
      };

      const script = document.createElement("script");
      script.src =
        "https://bofdevstorage.blob.core.windows.net/blobcontainer/crypto_trading_widget_sdk/index.js";
      document.head.appendChild(script);
      script.onload = () => {
        window.CryptoTradingWidget.initNftWidget("widget", configuration);
      };
    </script>

    <button id="orderButton">Open order</button>
 
    <script>
      const button = document.getElementById("orderButton");
      const openOrder = () => {
        const orderHash =
          "0xa35d92dad8c08d24b46ab0a8204768d4a5acbeb4dee21a04fd2616c7d0a5dfac";
        const chainId = 137;
        window.CryptoTradingWidget.openOrder(orderHash, chainId);
      };

      button.onclick = openOrder;
    </script>
  </body>
</html>
```

[^1]: is this div actually necessary tech-wise? The widget will be displayed as an overlay anyway, right? Why we don't inject it into the body transparently/automatically?&#x20;


---

# 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.bitoftrade.com/for-businesses/allpay-widget/quick-start/nft-widget-integration/code-integration.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.
