An Agent able to make calls and queries to a Replica.

Implements

Constructors

  • Parameters

    Returns utils.agent.ProxyAgent

Properties

_backend: any
_nextId: any
_pendingCalls: any
rootKey: null
_sendAndWait: any

Methods

  • Parameters

    Returns void

  • Returns the principal ID associated with this agent (by default). It only shows the principal of the default identity in the agent, which is the principal used when calls don't specify it.

    Returns Promise<types.Principal>

  • Send a read state query to the replica. This includes a list of paths to return, and will return a Certificate. This will only reject on communication errors, but the certificate might contain less information than requested.

    Parameters

    Returns Promise<utils.agent.ReadStateResponse>

  • Query the status endpoint of the replica. This normally has a few fields that corresponds to the version of the replica, its root public key, and any other information made public.

    Returns Promise<utils.candid.JsonObject>

    A JsonObject that is essentially a record of fields from the status endpoint.

  • Send a query call to a canister. See the interface spec.

    Parameters

    • canisterId: string | types.Principal

      The Principal of the Canister to send the query to. Sending a query to the management canister is not supported (as it has no meaning from an agent).

    • fields: utils.agent.QueryFields

      Options to use to create and send the query.

    Returns Promise<utils.agent.ApiQueryResponse>

    The response from the replica. The Promise will only reject when the communication failed. If the query itself failed but no protocol errors happened, the response will be of type QueryResponseRejected.

  • By default, the agent is configured to talk to the main Internet Computer, and verifies responses using a hard-coded public key.

    This function will instruct the agent to ask the endpoint for its public key, and use that instead. This is required when talking to a local test instance, for example.

    Only use this when you are not talking to the main Internet Computer, otherwise you are prone to man-in-the-middle attacks! Do not call this function by default.

    Returns Promise<ArrayBuffer>