# Extensions
Source: https://docs.chain.link/crec/concepts/extensions
Last Updated: 2026-08-31

> For the complete documentation index, see [llms.txt](/llms.txt).

An **extension** is an optional Go module that layers protocol-specific knowledge on top of the core CRE Connect SDK. Extensions ship three things:

1. **Typed Operation builders.** A `Prepare<Action>Operation(...)` function for every supported on-chain action, with strongly-typed Go arguments. The builder returns a fully-formed `*types.Operation` ready for `client.Transact.ExecuteOperation`.
2. **One-call watcher provisioning.** A registered service name plus the contract ABIs required to monitor a class of contracts. Watchers created with `CreateWithService(..., Service: "<service-name>")` use these.
3. **Decoded event types.** Strongly-typed Go structs for each event the watcher emits, so application code does not need to write ABI-decoding glue.

The currently available extension is **DTA (Digital Transfer Agent)**, distributed as `github.com/smartcontractkit/crec-sdk-ext-dta`. Its repository uses contract versioning to expose multiple ABI versions (`/v1`, `/v2`, …) under the same Go module. The CRE Connect documentation focuses on the `/v2` import path.

## Why use an extension

Without an extension you can still do anything CREC supports: call any contract through `Operation` + `Transaction`, and monitor any event through `CreateWithABI`. Extensions exist to remove the per-protocol boilerplate:

| Without an extension                     | With an extension                                                                  |
| ---------------------------------------- | ---------------------------------------------------------------------------------- |
| Hand-craft calldata via `abi.Pack`       | One typed Go call per on-chain action                                              |
| Supply the contract ABI to every watcher | Reference the service by name (`"dta.v2"`)                                         |
| Decode raw event topics yourself         | Receive a typed Go struct (e.g. `RedemptionRequested{ Shares, ReferenceID, ... }`) |
| Track ABI revisions per protocol upgrade | Bump the extension's Go module version                                             |

An extension is, at its heart, a vendored copy of "everything you would have written by hand" for a protocol, maintained alongside the protocol's own contracts so it stays accurate.

## Anatomy of an extension

Every CREC extension exposes the same shape:

(Image: Image)

### `operations.Extension`

A small client wired at construction time:

```go
import (
    "github.com/smartcontractkit/crec-sdk-ext-dta/v2/operations"
)

dta, err := operations.New(&operations.Options{
    AccountAddress:              smartAccountAddress.Hex(),  // hex string
    DTARequestManagementAddress: dtaManagementAddress.Hex(),
    DTARequestSettlementAddress: dtaSettlementAddress.Hex(),
})
```

`dta` exposes one `Prepare<Action>Operation(...)` per on-chain method. Each builder ABI-encodes the call, wraps it in a `Transaction`, and returns a `*types.Operation` with `Account` set to the configured `AccountAddress`.

### `watcher/bundle`

The `watcher/bundle` package declares the service name and its supported events:

```go
import bundle "github.com/smartcontractkit/crec-sdk-ext-dta/v2/watcher/bundle"

b := bundle.Get()  // b.Service == "dta.v2"
```

To create a watcher backed by the service, pass `Service: "dta.v2"` to `client.Watchers.CreateWithService(...)` along with the address of the contract you want to observe and the list of event names you care about. The service descriptor is consumed by the CRE Connect backend; applications do not pass it to `crec.NewClient`.

### `events` package and `DecodeFromEvent`

The `events` package contains one Go struct per event the service emits, for example `SubscriptionRequested`, `RedemptionRequested`, `DistributorRequestProcessing`. Each struct has typed fields matching the on-chain event signature.

`dtav2.DecodeFromEvent(ctx, ev)` (root of `crec-sdk-ext-dta/v2`) dispatches a verifiable event to the correct typed struct, returning a `DecodedEvent` whose `ConcreteEvent` field is the matching event struct.

## Combining extension calls with raw transactions

Because extension builders return a `*types.Operation` whose `Transactions` field is just a list, you can append extra `Transaction` entries to the same Operation before submitting:

```go
op, err := ext.PrepareRequestSubscriptionWithTokenApprovalOperation(/* ... */)
if err != nil { /* ... */ }

op.Transactions = append(op.Transactions, types.Transaction{
    To:    auxLogger,
    Value: big.NewInt(0),
    Data:  myAuxCalldata,
})

resp, err := client.Transact.ExecuteOperation(ctx, channelID, signer, op, chainSelector)
```

The whole composed Operation still executes atomically.

## Available extensions

| Extension                       | Module                                         | Documented import path |
| ------------------------------- | ---------------------------------------------- | ---------------------- |
| **DTA: Digital Transfer Agent** | `github.com/smartcontractkit/crec-sdk-ext-dta` | `/v2`                  |

The DTA extension repository uses contract versioning (`/v1`, `/v2`, …) to expose multiple deployed contract ABIs side-by-side. The CRE Connect documentation focuses on the `/v2` import path; if you operate against v1 contracts, import the `/v1` sub-package and consult the extension [README](https://github.com/smartcontractkit/crec-sdk-ext-dta#readme) for v1-specific operation signatures. See the [DTA Extension](/crec/extensions/dta) guides for the full v2 surface.

## Related

- [Extensions overview](/crec/extensions): the catalog of available extensions.
- [DTA v2](/crec/extensions/dta): the first GA extension.
- [Watchers](/crec/concepts/watchers): `CreateWithService` is how an extension's pre-packaged watcher is provisioned.