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
Extensionthat builds typed*types.Operationpayloads for every DTA contract function. - An
eventssub-package with one Go struct per emitted event and aDecodeFromEventhelper. - A
watcher/bundlepackage whose service descriptor CRE Connect loads to exposedta.v2as aServiceon 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:
AccountAddressmust be a hex address (this is theop.Accountyour operations target).DTARequestManagementAddressandDTARequestSettlementAddressmust both be valid hex addresses.Deadlineis 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:
| Group | Methods | Page |
|---|---|---|
| Subscriptions & redemptions | PrepareRequestSubscriptionOperation, PrepareRequestSubscriptionWithTokenApprovalOperation, PrepareRequestRedemptionOperation, PrepareCancelDistributorRequestOperation, PrepareProcessDistributorRequestOperation, PrepareCompleteRequestProcessingOperation | Subscriptions & Redemptions |
| Fund & distributor management | PrepareRegisterFundAdminOperation, PrepareRegisterFundTokenOperation, PrepareRegisterDistributorOperation, PrepareEnableFundTokenOperation, PrepareDisableFundTokenOperation, PrepareAuthorizeDistributorForTokenOperation, PrepareRevokeDistributorForTokenOperation, PrepareAllowDistributorForTokenOperation, PrepareDisallowDistributorForTokenOperation | Fund & Distributor Management |
| Cross-DTA settlement | PrepareAllowDTAOperation, PrepareDisallowDTAOperation, PrepareTransferDTARequestSettlementOwnershipOperation, PrepareRenounceDTARequestSettlementOwnershipOperation | Fund & Distributor Management |
| Operational | PrepareSetManagementCCIPGasLimitOperation, 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.