> For the complete documentation index, see [llms.txt](https://docs.derupt.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.derupt.io/latest/contracts/.derupt-ext-reg.md).

# .derupt-ext-reg

{% hint style="info" %}
**General:**

* A distinct **.derupt-ext** contract should be deployed by developer(s).&#x20;
* **.derupt-ext** contract(s) are used integrate 3rd party Stacks Smart contracts into the Derupt user experience during Derupt Core Operations.&#x20;
* `register-ext` function **must** be called by the extension contract deployer.&#x20;
  {% endhint %}

{% hint style="warning" %}
**Dev Warning:**

* **deploy a single** `.derupt-ext` contract to integrate w/ a single 3rd party contract function. &#x20;
* **users use your** `.derupt-ext`  contract as an `ext` argument in Derupt core operation calls.&#x20;
* **all extension arguments** are passed as `extras` during core operation function calls.\
  \&#xNAN;*(\* extension can use internal variables that do not require being passed if so desired)*&#x20;
* **to pass user input** as **`extras`** during **`ExtensionModal`** presentation, simply define the applicable `argsFromUser` via your [extension metadata.json description](https://docs.derupt.io/latest/contracts/.derupt-ext#extension-description-metadata)
  {% endhint %}

{% hint style="info" %}
Work in Progress
{% endhint %}

```
;; title: derupt-ext-reg
;; version: 1.3.1
;; summary: Extension Registry Contract
;; description: used to log extension registration

(use-trait derupt-ext-trait 'ST1ZK4MRVTQQJMVAAJQWBV2WPQ87QV2851YCTHD7X.derupt-ext-trait.derupt-ext)
;; (use-trait derupt-ext-trait 'MAINNETADDRESS.derupt-ext-trait.derupt-ext)

;; Error Constants
(define-constant ERR-UNAUTHORIZED (err u100))
(define-constant ERR-INVALID-PRINCIPAL (err u101))

(define-public (register-ext (ext-contract <derupt-ext-trait>))
    (let (
        (principal-data (unwrap! (principal-destruct? (contract-of ext-contract)) ERR-INVALID-PRINCIPAL))
        (version (get version principal-data))
        (hash-bytes (get hash-bytes principal-data))
        (ext-deployer (unwrap! (principal-construct? version hash-bytes) ERR-INVALID-PRINCIPAL))
    )
        (asserts! (is-eq tx-sender ext-deployer) ERR-UNAUTHORIZED)
        (print {ext-contract: (contract-of ext-contract)})
        (ok true)
    )
)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.derupt.io/latest/contracts/.derupt-ext-reg.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
