Table of Contents

Interface IContractStorage

Namespace
NArk.Abstractions.Contracts
Assembly
NArk.Abstractions.dll

Persistence for Arkade contracts; also drives active-script subscription via IActiveScriptsProvider.

public interface IContractStorage : IActiveScriptsProvider
Inherited Members

Methods

DeactivateAwaitingContractsByScript(string, CancellationToken)

Deactivates all contracts with the given script that are in AwaitingFundsBeforeDeactivate state. Called when a VTXO is received to auto-deactivate one-time-use contracts (like refund addresses).

Task<int> DeactivateAwaitingContractsByScript(string script, CancellationToken cancellationToken = default)

Parameters

script string

The script hex to match against contracts

cancellationToken CancellationToken

Cancellation token

Returns

Task<int>

Number of contracts deactivated

DeleteContract(string, string, CancellationToken)

Deletes a contract by script. Wallet ID guards ownership.

Task<bool> DeleteContract(string walletId, string script, CancellationToken cancellationToken = default)

Parameters

walletId string

The wallet ID that owns the contract

script string

The script hex of the contract to delete

cancellationToken CancellationToken

Cancellation token

Returns

Task<bool>

True if the contract was deleted, false if not found

GetContracts(string[]?, string[]?, bool?, string[]?, string?, int?, int?, ContractScope?, CancellationToken)

Query contracts with explicit filter parameters. Adding new parameters will cause compile errors for implementors, ensuring they handle new filters.

Task<IReadOnlyCollection<ArkContractEntity>> GetContracts(string[]? walletIds = null, string[]? scripts = null, bool? isActive = null, string[]? contractTypes = null, string? searchText = null, int? skip = null, int? take = null, ContractScope? scope = null, CancellationToken cancellationToken = default)

Parameters

walletIds string[]

Filter by wallet IDs. If null, all wallets.

scripts string[]

Filter by script hex strings. If null, no script filter.

isActive bool?

If true, only active (not Inactive); if false, only Inactive; if null, all.

contractTypes string[]

Filter by contract types. If null, no type filter.

searchText string

Filter by script containing this text. If null, no text filter.

skip int?

Number of records to skip (for pagination). If null, no skip.

take int?

Number of records to take (for pagination). If null, no limit.

scope ContractScope?

Filter by contract scope (on-chain/off-chain) via bitwise include (Scope & scope) == scope. If null, no scope filter.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyCollection<ArkContractEntity>>

SaveContract(ArkContractEntity, CancellationToken)

Inserts or updates a contract record.

Task SaveContract(ArkContractEntity walletEntity, CancellationToken cancellationToken = default)

Parameters

walletEntity ArkContractEntity
cancellationToken CancellationToken

Returns

Task

UpdateContractActivityState(string, string, ContractActivityState, CancellationToken)

Updates the activity state of a contract.

Task<bool> UpdateContractActivityState(string walletId, string script, ContractActivityState activityState, CancellationToken cancellationToken = default)

Parameters

walletId string

The wallet ID that owns the contract

script string

The script hex of the contract

activityState ContractActivityState

The new activity state

cancellationToken CancellationToken

Cancellation token

Returns

Task<bool>

True if the contract was found and updated, false otherwise

Events

ContractsChanged

Raised when a contract is saved or its activity state changes.

event EventHandler<ArkContractEntity>? ContractsChanged

Event Type

EventHandler<ArkContractEntity>