Skip to content

SignerAgent

Defined in: src/agent/agent.ts:100

An Agent implementation that routes canister calls through a Signer for user approval. Drop-in replacement for HttpAgent when canister calls need to be signed by an external signer.

Calls are sent to the signer via ICRC-49, and the returned content map and certificate are validated before being returned to the caller.

Use SignerAgent.create or SignerAgent.createSync to construct an instance — the constructor is private.

const agent = await SignerAgent.create({ signer, account });
const result = await agent.update(canisterId, { methodName: "transfer", arg, effectiveCanisterId: canisterId });

T extends Transport = Transport

  • Agent

get rootKey(): Uint8Array<ArrayBufferLike>

Defined in: src/agent/agent.ts:116

The root key used for certificate verification.

Uint8Array<ArrayBufferLike>

Agent.rootKey


get signer(): Signer<T>

Defined in: src/agent/agent.ts:121

The signer this agent routes calls through.

Signer<T>

call(canisterId, fields): Promise<SubmitResponse>

Defined in: src/agent/agent.ts:237

Sends a canister call through the signer. Returns the request ID and a synthetic HTTP response.

string | Principal

The target canister principal or its text representation.

CallOptions

The call options including method name and arguments.

Promise<SubmitResponse>

Agent.call


createReadStateRequest(_options, _identity?): Promise<unknown>

Defined in: src/agent/agent.ts:333

Internal

ReadStateOptions

The read state options.

Identity

The identity to use for the request.

Promise<unknown>

Agent.createReadStateRequest


fetchRootKey(): Promise<Uint8Array<ArrayBufferLike>>

Defined in: src/agent/agent.ts:319

Fetches the IC root key via the underlying HttpAgent.

Promise<Uint8Array<ArrayBufferLike>>

Agent.fetchRootKey


getPrincipal(): Promise<Principal>

Defined in: src/agent/agent.ts:324

Returns the account principal this agent makes calls on behalf of.

Promise<Principal>

Agent.getPrincipal


query(canisterId, options, _identity?): Promise<ApiQueryResponse>

Defined in: src/agent/agent.ts:294

Executes a query by upgrading it to a canister call through the signer. The signer signs and submits the call, and the reply is extracted from the certified response.

string | Principal

The target canister principal or its text representation.

QueryFields

The query fields including method name and arguments.

Identity | Promise<Identity>

Ignored. The signer manages identity internally.

Promise<ApiQueryResponse>

Agent.query


readState(_canisterId, options, _identity?, _request?): Promise<ReadStateResponse>

Defined in: src/agent/agent.ts:348

Returns the raw certificate for a previously completed call. The certificate is deleted after being read (single-use).

Only supports request_status paths for request IDs that were returned by a prior call, update, or query.

string | Principal

The target canister principal (unused).

ReadStateOptions

The read state options containing paths to look up.

Identity | Promise<Identity>

The identity to use (unused).

unknown

The request object (unused).

Promise<ReadStateResponse>

Agent.readState


replaceAccount(account): void

Defined in: src/agent/agent.ts:380

Replaces the account principal used for subsequent calls.

Principal

The new account principal to use for subsequent calls.

void


status(): Promise<JsonObject>

Defined in: src/agent/agent.ts:372

Queries the IC replica status via the underlying HttpAgent.

Promise<JsonObject>

Agent.status


update(canisterId, fields, _pollingOptions?): Promise<UpdateResult>

Defined in: src/agent/agent.ts:261

Executes a canister update call and returns the certified result. Combines call with certificate validation and reply extraction.

string | Principal

The target canister principal or its text representation.

CallOptions

The call options including method name and arguments.

unknown

Ignored. The signer already returns the certificate with the reply in a single round-trip.

Promise<UpdateResult>

Agent.update


static create<T>(options): Promise<SignerAgent<T>>

Defined in: src/agent/agent.ts:130

Creates a new SignerAgent, asynchronously initializing the underlying HttpAgent if one is not provided.

T extends Transport

SignerAgentOptions<T>

The signer agent options.

Promise<SignerAgent<T>>


static createSync<T>(options): SignerAgent<T>

Defined in: src/agent/agent.ts:143

Creates a new SignerAgent synchronously. Use this when you already have an HttpAgent or don’t need async initialization.

T extends Transport

SignerAgentOptions<T>

The signer agent options.

SignerAgent<T>