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

# claimYieldRewards

# claimYieldRewards

Claims a wallet account's accrued rewards in an [Earn](/docs/overview/yield) vault, then signs and sends the resulting transaction. The reward distributor's address and the per-user merkle proof are resolved server-side — you only pass a `vaultId`.

Rejects when there is nothing claimable for this vault right now — no active reward campaign, or every attributable token is already fully claimed. Check [`getYieldRewards`](/docs/javascript/reference/client/get-yield-rewards) before calling, and only show a claim action when it returns a non-zero `accrued` amount.

## Usage

```javascript theme={"system"}
import { claimYieldRewards } from '@dynamic-labs-sdk/client';

const { transactionHash } = await claimYieldRewards({
  vaultId: 'fb-eth-galaxy-usdc-fw-01',
  walletAccount,
});

console.log('Transaction hash:', transactionHash);
```

## Parameters

| Parameter       | Type                       | Description                                                                                        |
| --------------- | -------------------------- | -------------------------------------------------------------------------------------------------- |
| `vaultId`       | `string`                   | Opaque vault identifier, from [`listYieldVaults`](/docs/javascript/reference/client/list-yield-vaults). |
| `walletAccount` | `WalletAccount`            | The wallet account whose accrued rewards are being claimed. Must be an EVM wallet account.         |
| `client`        | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple Dynamic clients.                    |

## Returns

`Promise<{ transactionHash: string }>` - The hash of the claim transaction.

## Examples

### Only offer claim when something is claimable

```javascript theme={"system"}
import { claimYieldRewards, getYieldRewards } from '@dynamic-labs-sdk/client';

async function claimIfAvailable(vaultId, walletAccount) {
  const rewards = await getYieldRewards({ vaultId, walletAccount });
  const claimable = rewards.some(
    (reward) => reward.accrued && reward.accrued !== '0'
  );

  if (!claimable) {
    return null;
  }

  return claimYieldRewards({ vaultId, walletAccount });
}
```

## Supported Chains

`claimYieldRewards` only supports EVM wallet accounts — vault actions are EVM-only today. Calling it with a non-EVM `walletAccount` throws a `WalletProviderMethodUnavailableError`, since only EVM wallet providers implement the underlying `executeYieldTransaction` method.

## React

```tsx theme={"system"}
import { useClaimYieldRewards } from '@dynamic-labs-sdk/react-hooks';

function ClaimButton({ vaultId, walletAccount }) {
  const { mutate: claim, isPending, error } = useClaimYieldRewards();

  return (
    <>
      <button
        onClick={() => claim({ vaultId, walletAccount })}
        disabled={isPending}
      >
        Claim rewards
      </button>
      {error && <p>Nothing to claim right now.</p>}
    </>
  );
}
```

`useClaimYieldRewards` invalidates [`useGetYieldRewards`](/docs/javascript/reference/client/get-yield-rewards) on success — treat that refetch as a nudge, since the claim is only broadcast (not necessarily mined) when the mutation resolves.

## Related

* [`getYieldRewards`](/docs/javascript/reference/client/get-yield-rewards) - Check accrued rewards before claiming
* [`depositToYieldVault`](/docs/javascript/reference/client/deposit-to-yield-vault) - Deposit into a vault
