createAgent() function

Helper function to create a new instance of the Agent class with correct type

Signature:
export declare function createAgent<T extends IPluginMethodMap>(options: IAgentOptions): TAgent<T>

Parameters

ParameterTypeDescription
optionsIAgentOptionsAgent configuration options
Returns:

TAgent <T>

configured agent

Remarks

Use TAgent to configure agent type (list of available methods) for autocomplete in IDE

Example

import { createAgent, IResolver, IMessageHandler } from '@veramo/core'
import { AgentRestClient } from '@veramo/remote-client'
import { CredentialIssuer, ICredentialIssuer } from '@veramo/credential-w3c'
const agent = createAgent<IResolver & IMessageHandler & ICredentialIssuer>({
plugins: [
new CredentialIssuer(),
new AgentRestClient({
url: 'http://localhost:3002/agent',
enabledMethods: ['resolveDid', 'handleMessage'],
}),
],
})