# pinPollingIdentity

> **pinPollingIdentity**(`agent`, `identity`): `Agent`

Defined in: [utils/agent.ts:107](https://github.com/B3Pay/ic-reactor/blob/2de45f357e6c8bcfa7cb2aa71eff7a059eacdf01/packages/core/src/utils/agent.ts#L107)

Wrap `agent` so that every read_state `pollForResponse` sends is signed by
`identity` — the one that submitted the call — rather than by whatever the
shared agent holds by the time each poll goes out.

`HttpAgent.readState` takes an identity parameter and ignores it: the
declaration names it `_identity`, and the body signs a fresh request with
the agent's own identity on every call. The one input it sends verbatim is a
pre-signed `request`, so that is where the pin has to live. The request is
built through `createReadStateRequest`, which does honour an explicit
identity, and is rebuilt on every poll so each carries a fresh ingress
expiry, exactly as the unpinned path does.

`createReadStateRequest` is overridden too, for two reasons. With
`preSignReadStateRequest: true`, `pollForResponse` calls it on the agent it
was handed and passes no identity, so it has to default to the pinned one.
And a prototype delegate must never let an `HttpAgent` method run with the
delegate as `this`: those methods touch private fields, which throw on any
object that is not the instance itself. Both overrides call the real agent.

Everything else — transforms, root key, subnet-key cache, time sync — is
still the underlying agent's, reached through the prototype chain.

As of @icp-sdk/core 6.1.0 the `preSignReadStateRequest` path never gets as
far as the read: `pollForResponse` validates the built request by looking
for `toHash` as an own property of the expiry, which `Expiry` defines on its
prototype, so every `HttpAgent` request is rejected as invalid. That is
upstream and independent of this wrapper; the default path is the one that
runs.

## Parameters

### agent

`Agent`

### identity

`Identity`

## Returns

`Agent`