API Quick Reference
Quick lookup table of all TrustWeave API methods organized by category.
DIDs
Credentials
| Method |
Description |
Link |
issue { } |
Issue a verifiable credential |
issue() |
verify { } |
Verify a verifiable credential |
verify() |
Wallets
| Method |
Description |
Link |
wallet { } |
Create a wallet |
wallet() |
wallet.store(credential) |
Store a credential in wallet |
Wallet API |
wallet.get(credentialId) |
Get credential by ID |
Wallet API |
wallet.list() |
List all credentials |
Wallet API |
wallet.query { } |
Query credentials with filters |
Wallet API |
Blockchain Anchoring
| Method |
Description |
Link |
anchor { } |
Anchor data to blockchain |
anchor() |
readAnchor { } |
Read anchored data |
readAnchor() |
Delegation
| Method |
Description |
Link |
delegate { } |
Delegate authority between DIDs |
delegate() |
Key Management
| Method |
Description |
Link |
rotateKey { } |
Rotate keys in DID documents |
rotateKey() |
Methods by Category
DID Operations
Create DID:
1
2
3
4
5
6
7
| import com.trustweave.trust.types.Did
val did: Did = trustWeave.createDid {
method("key")
algorithm("Ed25519")
}
// Access DID string value: did.value
|
Resolve DID:
1
2
3
4
| import com.trustweave.trust.types.Did
val did = Did("did:key:example")
val document = trustWeave.context.resolveDid(did)
|
Update DID:
1
2
3
4
| val updated = trustLayer.updateDid {
did("did:key:example")
addService { ... }
}
|
Deactivate DID:
1
| val deactivated = trustLayer.deactivateDid("did:key:example")
|
Credential Operations
Issue Credential:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| import com.trustweave.trust.types.IssuerIdentity
val issuerIdentity = IssuerIdentity.from(issuerDid, keyId)
val credential = trustWeave.issue {
credential {
type("VerifiableCredential", "PersonCredential")
issuer(issuerDid)
subject {
id("did:key:holder")
"name" to "Alice"
}
}
signedBy(issuerIdentity)
}
|
Verify Credential:
1
2
3
4
5
6
7
8
9
10
11
| import com.trustweave.trust.types.VerificationResult
val result: VerificationResult = trustWeave.verify {
credential(credential)
}
when (result) {
is VerificationResult.Valid -> println("Valid!")
is VerificationResult.Invalid.Expired -> println("Expired")
// ... exhaustive error handling
}
|
Wallet Operations
Create Wallet:
1
2
3
4
5
| val wallet = trustLayer.wallet {
holder("did:key:holder")
enableOrganization()
enablePresentation()
}
|
Store Credential:
1
| val credentialId = wallet.store(credential)
|
Query Credentials:
1
2
3
4
5
| val results = wallet.query {
byIssuer("did:key:issuer")
notExpired()
byType("PersonCredential")
}
|
Blockchain Operations
Anchor Data:
1
2
3
4
| val anchorResult = trustLayer.anchor {
data(digest)
chain("algorand:testnet")
}
|
Read Anchored Data:
1
2
3
| val data = trustLayer.readAnchor<MyData> {
ref(anchorRef)
}
|
Delegation Operations
Delegate Authority:
1
2
3
4
5
| val delegation = trustLayer.delegate {
from("did:key:delegator")
to("did:key:delegatee")
capability("issue")
}
|
Key Rotation
Rotate Key:
1
2
3
4
5
| val updated = trustLayer.rotateKey {
did("did:key:example")
oldKeyId("did:key:example#key-1")
newAlgorithm("Ed25519")
}
|