> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# getValidators

> Returns the available validators for a native-staking yield.

**Function Signature**

```swift theme={null}
public func getValidators(yieldId: String) async throws -> [YieldXyzValidator]
```

Available on both the namespace and the provider. `portal.yield.getValidators(yieldId:)` is a passthrough to `portal.yield.yieldxyz.getValidators(yieldId:)`.

**Description**

Fetches the validators available for a native-staking yield. Use the returned addresses to populate `arguments.validatorAddress` on a [`deposit`](./yielddeposit), or to drive a validator picker in your UI.

**Parameters**

| Parameter | Type     | Required | Description                                                             |
| --------- | -------- | -------- | ----------------------------------------------------------------------- |
| `yieldId` | `String` | Yes      | The yield identifier, for example `"monad-testnet-mon-native-staking"`. |

**Returns**

**`[YieldXyzValidator]`**

Only `address` is non-optional. Every other field depends on the protocol and may be absent:

| Property                    | Type                  | Description                                                                         |
| --------------------------- | --------------------- | ----------------------------------------------------------------------------------- |
| `address`                   | `String`              | Validator address. The only guaranteed field.                                       |
| `name`                      | `String?`             | Display name.                                                                       |
| `logoURI`                   | `String?`             | Logo URL.                                                                           |
| `website`                   | `String?`             | Validator website.                                                                  |
| `rewardRate`                | `YieldXyzRewardRate?` | Current reward rate.                                                                |
| `provider`                  | `YieldXyzProvider?`   | Provider metadata — `name`, `uniqueId`, `website`, `rank`, `preferred`, `revshare`. |
| `commission`                | `Double?`             | Commission rate.                                                                    |
| `tvlUsd` / `tvl` / `tvlRaw` | `String?`             | Total value locked, in various denominations.                                       |
| `votingPower`               | `Double?`             | Share of total voting power.                                                        |
| `preferred`                 | `Bool?`               | Whether the validator is preferred.                                                 |
| `minimumStake`              | `String?`             | Minimum stake accepted.                                                             |
| `remainingPossibleStake`    | `String?`             | Remaining capacity.                                                                 |
| `remainingSlots`            | `Int?`                | Remaining delegation slots.                                                         |
| `nominatorCount`            | `Int?`                | Number of nominators.                                                               |
| `status`                    | `String?`             | Validator status.                                                                   |
| `providerId`                | `String?`             | Provider identifier.                                                                |
| `pricePerShare`             | `String?`             | Price per share.                                                                    |
| `subnetId` / `subnetName`   | `Int?` / `String?`    | Subnet identifiers, where applicable.                                               |
| `marketCap`                 | `String?`             | Market capitalization.                                                              |
| `tokenSymbol`               | `String?`             | Staked token symbol.                                                                |

**Throws**

| Case                                 | When                                                                           |
| ------------------------------------ | ------------------------------------------------------------------------------ |
| `YieldXyzError.noValidators(String)` | The response contained no validators, or an empty list. Carries the `yieldId`. |
| `YieldXyzError.apiError(String)`     | The backend returned an error payload. Carries the message.                    |

Network errors propagate as thrown errors.

**Example Usage**

```swift theme={null}
import PortalSwift

do {
    let validators = try await portal.yield.getValidators(yieldId: "monad-testnet-mon-native-staking")

    for validator in validators {
        print(validator.address, validator.name ?? "unnamed", validator.commission ?? 0)
    }
} catch YieldXyzError.noValidators(let yieldId) {
    print("No validators for \(yieldId) — it may not be a native-staking yield")
} catch {
    print("getValidators failed: \(error)")
}
```

Using a validator in a deposit:

```swift theme={null}
let validators = try await portal.yield.getValidators(yieldId: yieldId)

guard let validator = validators.first else {
    throw YieldXyzError.noValidators(yieldId)
}

let result = try await portal.yield.yieldxyz.deposit(
    params: YieldDepositParams(
        target: .yieldId(yieldId),
        amount: "1.0",
        arguments: YieldXyzEnterArguments(validatorAddress: validator.address)
    )
)
```

**Related Documentation**

* [Earn with Yield.xyz](../guide/yield-xyz)
* [deposit](./yielddeposit)
* [withdraw](./yieldwithdraw)
* [Yield.xyz Integration](/integrations/Yield/yield-xyz)
