Extensions

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 extensionWith an extension
Hand-craft calldata via abi.PackOne typed Go call per on-chain action
Supply the contract ABI to every watcherReference the service by name ("dta.v2")
Decode raw event topics yourselfReceive a typed Go struct (e.g. RedemptionRequested{ Shares, ReferenceID, ... })
Track ABI revisions per protocol upgradeBump 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:

operations.Extension

A small client wired at construction time:

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:

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:

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

ExtensionModuleDocumented import path
DTA: Digital Transfer Agentgithub.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 for v1-specific operation signatures. See the DTA Extension guides for the full v2 surface.

  • Extensions overview: the catalog of available extensions.
  • DTA v2: the first GA extension.
  • Watchers: CreateWithService is how an extension's pre-packaged watcher is provisioned.

Get the latest Chainlink content straight to your inbox.