> For the complete documentation index, see [llms.txt](https://docs.stacks.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stacks.co/reference/stacks.js/stacks-bitcoin-staking/eligibility/eligibilityresult.md).

# EligibilityResult

The result of every `fetchEligible*` preflight: `{ ok: true }` when no checked gate would fail, or `{ ok: false, reasons }` with the pox-5 error code of each gate that would. Returned by [fetchEligibleRegisterForBond](/reference/stacks.js/stacks-bitcoin-staking/eligibility/fetcheligibleregisterforbond.md), [fetchEligibleStake](/reference/stacks.js/stacks-bitcoin-staking/eligibility/fetcheligiblestake.md) and the other `fetchEligible*` functions.

***

### Usage

```ts
import { describePox5Error, fetchEligibleUnstake } from '@stacks/bitcoin-staking';

const result = await fetchEligibleUnstake({
  staker: 'SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE',
  oldSignerManager: 'SP2C2YFP12AJZB4MABJBAJ55XECVS7E4PMMZ89YZR.my-signer-manager',
  network: 'mainnet',
});

if (!result.ok) {
  for (const code of result.reasons) {
    console.log(code, describePox5Error(code)?.name); // e.g. 27 'ERR_NOT_STAKING'
  }
}
```

#### Notes

* `reasons` always has at least one entry when `ok` is `false`. The type is a non-empty tuple.
* Treat `reasons` as a set. The contract aborts at the first failing assert in its own order, so the code a transaction fails with need not be `reasons[0]`.
* `{ ok: true }` covers only the gates the function checks, at the Bitcoin block height it read. Each function's page lists the gates it does not check, such as the signer-manager's `validate-stake!` call. A transaction can still fail if chain state changes before it is mined.

[**Reference Link**](https://github.com/stx-labs/stacks.js/blob/6101c99efe5a9616ce7e16cef68e28fd10676e7e/packages/bitcoin-staking/src/eligibility.ts#L43-L55)

***

### Definition

```ts
type EligibilityResult =
  | { ok: true }
  | { ok: false; reasons: [Pox5ErrorCode, ...Pox5ErrorCode[]] };
```

***

### Values

| Value                                                         | Description                                                                                                                                                                                    |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `{ ok: true }`                                                | No checked gate would fail                                                                                                                                                                     |
| `{ ok: false; reasons: [Pox5ErrorCode, ...Pox5ErrorCode[]] }` | At least one checked gate would fail. Each entry is a [Pox5ErrorCode](/reference/stacks.js/stacks-bitcoin-staking/errors/pox5errorcode.md): the number the contract would return as `(err uN)` |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stacks.co/reference/stacks.js/stacks-bitcoin-staking/eligibility/eligibilityresult.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
