API Reference
Complete API reference for TrustWeave.
Quick Reference
| Category | Methods | Page |
|---|---|---|
| DIDs | createDid(), resolveDid(), updateDid(), deactivateDid() |
Core API |
| Credentials | issue(), verify(), present() |
Core API |
| Wallets | create(), store(), query(), present() |
Wallet API |
| Blockchain | anchor(), read(), verify() |
Core API |
| Smart Contracts | draft(), bindContract(), executeContract() |
Smart Contract API |
| Trust | addTrustAnchor(), isTrustedIssuer(), getTrustPath() |
Core API |
Core API
- Core API: TrustWeave facade API
- DID operations (
dids.create(),dids.resolve(),dids.update(),dids.deactivate()) - Credential operations (
credentials.issue(),credentials.verify()) - Wallet operations (
wallets.create()) - Blockchain anchoring (
blockchains.anchor(),blockchains.read()) - Smart contract operations (
contracts.draft(),contracts.bindContract(),contracts.executeContract(), etc.) - Plugin lifecycle management (
initialize(),start(),stop(),cleanup()) - Error handling with
TrustWeaveErrortypes
- DID operations (
Service APIs
- Wallet API: Wallet operations and capabilities
- Credential storage
- Credential organization (collections, tags, metadata)
- Credential lifecycle (archive, refresh)
- Credential presentation
- DID management
- Key management
- Credential issuance
- Credential Service API: Credential service SPI
- Credential issuance
- Credential verification
- Presentation creation
- Presentation verification
- Provider registration
- Type-safe options
- Smart Contract API: Smart Contract operations
- Contract creation and lifecycle
- Binding with verifiable credentials
- Blockchain anchoring
- Contract execution
- Condition evaluation
- State management
Error Handling
Most TrustWeave API operations throw TrustWeaveError exceptions on failure. Some operations (like contract operations) return Result<T> directly. Check the method signature for each operation.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import com.trustweave.core.*
try {
val did = trustWeave.createDid { method("key") }
val credential = trustWeave.issue {
credential { issuer(did.value); subject { id(did.value) } }
signedBy(issuerDid = did.value, keyId = "key-1")
}
val wallet = trustWeave.wallet {
id("wallet-1")
holder(did.value)
}
} catch (error: TrustWeaveError) {
when (error) {
is TrustWeaveError.DidMethodNotRegistered -> {
println("Method not registered: ${error.method}")
println("Available methods: ${error.availableMethods}")
}
is TrustWeaveError.ChainNotRegistered -> {
println("Chain not registered: ${error.chainId}")
println("Available chains: ${error.availableChains}")
}
else -> println("Error: ${error.message}")
}
}
See Error Handling for detailed error handling patterns.
Configuration
TrustWeave is configured during creation using a DSL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
val trustweave = TrustWeave.create {
kms = InMemoryKeyManagementService()
walletFactory = TestkitWalletFactory()
didMethods {
+ DidKeyMethod()
+ DidWebMethod()
}
blockchains {
"algorand:testnet" to algorandClient
"polygon:mainnet" to polygonClient
}
credentialServices {
+ MyCredentialService()
}
}
Plugin Lifecycle
Manage plugin initialization and cleanup:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
val trustweave = TrustWeave.create()
// Initialize plugins
try {
trustweave.initialize()
trustweave.start()
// Use TrustWeave
// ...
trustweave.stop()
trustweave.cleanup()
} catch (error: TrustWeaveError) {
println("Plugin lifecycle error: ${error.message}")
}
See Plugin Lifecycle for detailed plugin lifecycle management.
Next Steps
New to TrustWeave?
- Getting Started - Installation and setup
- Quick Start - Your first application
- Core Concepts - Understand DIDs, credentials, and wallets
- Mental Model - Understand how TrustWeave works
Ready to dive deeper?
- Error Handling - Error handling patterns
- Plugin Lifecycle - Plugin lifecycle management
- Common Patterns - Production-ready patterns
- Tutorials - Step-by-step guides
- Use Case Scenarios - Real-world examples
Looking for specific APIs?
- Core API - TrustLayer facade API (DIDs, credentials, wallets, blockchain)
- Wallet API - Wallet operations and capabilities
- Credential Service API - Credential service SPI
- Smart Contract API - Smart contract operations