DTA v2 Overview

The DTA v2 extension (github.com/smartcontractkit/crec-sdk-ext-dta/v2) packages everything needed to drive the DTA contracts from CRE Connect:

  • An Extension that builds typed *types.Operation payloads for every DTA contract function.
  • An events sub-package with one Go struct per emitted event and a DecodeFromEvent helper.
  • A watcher/bundle package whose service descriptor CRE Connect loads to expose dta.v2 as a Service on watchers: one SDK call provisions every watcher the integration needs.

Module layout

crec-sdk-ext-dta/v2
├── v2.go                       // root package; exposes DecodeFromEvent + DecodedEvent
├── operations/                 // PrepareXxxOperation builders for every DTA function
│   ├── extension_gen.go        // Options, New, Extension struct
│   ├── operations_gen.go       // 21 generated PrepareXxxOperation methods
│   └── operations.go           // 2 hand-written helpers (with token approval, etc.)
├── events/                     // Typed event structs + EventName enum
│   ├── events_gen.go           // 28 EventName constants + payload structs
│   ├── decode_gen.go           // EventDecoders map per event
│   └── types.go                // Shared types (FundTokenData, DistributorRequest, RequestStatus, ...)
├── watcher/
│   └── bundle/bundle.go        // bundle.Get(): service name + ABIs (consumed by CRE Connect)
└── fee_manager/                // Optional fee-manager sub-extension (out of scope)

When to use the DTA v2 extension

Use it whenever your application calls the DTA Request Management or DTA Request Settlement contracts. The extension covers every public function on both contracts, so any flow described in the DTA standard, including onboarding, allowlisting, subscriptions / redemptions, and settlement, is one PrepareXxxOperation call away.

If you are emitting verifiable events from a different smart-contract suite (i.e. not DTA), write a custom watcher with Watchers.CreateWithABI instead.

Construct the extension

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

client, _ := crec.NewClient(baseURL, apiKey)

ext, err := dtaop.New(&dtaop.Options{
    AccountAddress:              smartAccount.Hex(),
    DTARequestManagementAddress: managementAddr.Hex(),
    DTARequestSettlementAddress: settlementAddr.Hex(),
})
if err != nil { return err }

Options are validated:

  • AccountAddress must be a hex address (this is the op.Account your operations target).
  • DTARequestManagementAddress and DTARequestSettlementAddress must both be valid hex addresses.
  • Deadline is optional; if set, every prepared operation gets that deadline by default.

The service descriptor (dtabundle.Get()) is consumed by CRE Connect, not by the SDK client. You only need to import it when you want to inspect its metadata (service name, event list) from your application code.

Categories of operations

The 23 PrepareXxxOperation methods split into four groups:

GroupMethodsPage
Subscriptions & redemptionsPrepareRequestSubscriptionOperation, PrepareRequestSubscriptionWithTokenApprovalOperation, PrepareRequestRedemptionOperation, PrepareCancelDistributorRequestOperation, PrepareProcessDistributorRequestOperation, PrepareCompleteRequestProcessingOperationSubscriptions & Redemptions
Fund & distributor managementPrepareRegisterFundAdminOperation, PrepareRegisterFundTokenOperation, PrepareRegisterDistributorOperation, PrepareEnableFundTokenOperation, PrepareDisableFundTokenOperation, PrepareAuthorizeDistributorForTokenOperation, PrepareRevokeDistributorForTokenOperation, PrepareAllowDistributorForTokenOperation, PrepareDisallowDistributorForTokenOperationFund & Distributor Management
Cross-DTA settlementPrepareAllowDTAOperation, PrepareDisallowDTAOperation, PrepareTransferDTARequestSettlementOwnershipOperation, PrepareRenounceDTARequestSettlementOwnershipOperationFund & Distributor Management
OperationalPrepareSetManagementCCIPGasLimitOperation, PrepareSetSettlementCCIPGasLimitOperation, PrepareWithdrawManagementTokensOperation, PrepareWithdrawSettlementTokensOperation(covered inline in Fund & Distributor Management)

Sample flow

End-to-end: register a distributor, subscribe to a fund token, watch for the resulting events.

op, err := ext.PrepareRegisterDistributorOperation(distributorWalletAddr)
if err != nil { return err }
if _, err := client.Transact.ExecuteOperation(ctx, channelID, signer, op, chainSelector); err != nil {
    return err
}

op2, _ := ext.PrepareRequestSubscriptionWithTokenApprovalOperation(
    fundAdminAddr, fundTokenId, amount, referenceID, paymentTokenAddr,
)
if _, err := client.Transact.ExecuteOperation(ctx, channelID, signer, op2, chainSelector); err != nil {
    return err
}

events, _, _ := client.Events.Poll(ctx, channelID, nil)
for _, ev := range events {
    decoded, err := dtav2.DecodeFromEvent(ctx, ev)
    if err != nil { continue }
    switch v := decoded.ConcreteEvent.(type) {
    case dtaevents.SubscriptionRequested:
        log.Printf("subscription %s shares pending", v.RequestId.Hex())
    case dtaevents.DistributorRegistered:
        log.Printf("distributor %s online", v.DistributorAddr.Hex())
    }
}

Watcher provisioning

Pass Service: "dta.v2" to Watchers.CreateWithService along with the events you want to subscribe to. The DTA service publishes 11 events you can subscribe to (the full list is exposed via bundle.Get().Events); list whichever subset your integration needs.

import "github.com/smartcontractkit/crec-sdk/watchers"

w, err := client.Watchers.CreateWithService(ctx, channelID, watchers.CreateWithServiceInput{
    Name:          "dta-management",
    ChainSelector: chainSelector,
    Service:       "dta.v2",
    Address:       managementAddr.Hex(),
    Events: []string{
        "SubscriptionRequested",
        "RedemptionRequested",
        "DistributorRequestProcessing",
        "DistributorRequestProcessed",
    },
})

CRE Connect owns the ABIs: you only need to know the event names you want to receive.

What's next

Get the latest Chainlink content straight to your inbox.