Function: useCastor()

typescript
1
useCastor(resolvers): Castor

Defined in: packages/identus-react/src/hooks/useCastor.ts:45

Creates and returns a memoized instance of Castor with optional additional resolvers.

Castor is the cryptographic component of the Identus SDK responsible for DID operations, key management, and cryptographic functions. It can be extended with additional DID resolvers.

Parameters

resolvers

ExtraResolver[] = []

Optional array of additional DID resolver constructors to extend Castor functionality

Returns

Castor

Castor Context

Example

tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { useCastor } from '@trust0/identus-react/hooks';
function DIDManager() {
// Basic usage without additional resolvers
const castor = useCastor();
// Usage with custom resolvers
const castorWithResolvers = useCastor([CustomResolver1, CustomResolver2]);
const resolveDID = async () => {
try {
const didDocument = await castor.resolveDID(SDK.Domain.DID.fromString('did:prism:example'));
console.log('Resolved DID:', didDocument.toString());
} catch (error) {
console.error('Failed to resolve DID:', error);
}
};
return (
<button onClick={resolveDID}>
Resolve DID
</button>
);
}