# .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)
    )
)
```
