# Voting for a Validator

### Vote/Stake to a Validator

{% tabs %}
{% tab title="UI" %}

Step1: Navigate to <https://dao.rei.network/#/stake>&#x20;

![](/files/8cSCj4tOvSdMpaR0bUbu)

Step2: Click on `Voting to Validator`, enter validator `address` and submit the `amount` you want to stake/vote

![](/files/9zQbLYByNQj1rykvXhLn)
{% endtab %}

{% tab title="Ethers" %}

```typescript
import { getDefaultProvider, Wallet } from "ethers";
import { StakeManager__factory } from "@rei-network/contracts";

const provider = getDefaultProvider("https://rpc-mainnet.rei.network");

const wallet = new Wallet("yourPrivateKey", provider);

const stakeManager = StakeManager__factory.connect(
  "0x0000000000000000000000000000000000001001",
  wallet
);

stakeManager
  .stake("validatorAddress", "receiveAddress", {
    value: "stakeAmount",
  })
  .then(() => {
    // ...
  })
  .catch(() => {
    // ...
  });
```

{% endtab %}
{% endtabs %}

> #### Why am I not able to Stake?&#x20;
>
> Check if you have `REI` in your wallet on REI Network
>
> #### I've staked to 0x...abcd, but not record find in ACTIVE VALIDATOR?
>
> Because only the 21 nodes with the most votes are currently displayed in the list of activated nodes

### UnVote/UnStake

{% tabs %}
{% tab title="UI" %}
Once you log in you will find this on the Validator of the Staking Dashboard. Here you will see an `Unstake` button for each of the validators. Click on the `Unstake` button for whichever validator that you had staked to.

![](/files/T6IqHt4nI9Io8lWZbSUv)
{% endtab %}

{% tab title="Ethers" %}

```typescript
import { getDefaultProvider, Wallet, BigNumber } from "ethers";
import {
  CommissionShare__factory,
  StakeManager__factory,
  CommissionShare,
} from "@rei-network/contracts";

const provider = getDefaultProvider("https://rpc-mainnet.rei.network");

const wallet = new Wallet("yourPrivateKey", provider);

const stakeManager = StakeManager__factory.connect(
  "0x0000000000000000000000000000000000001001",
  wallet
);

(async () => {
  try {
    let cs: CommissionShare;
    // get commission share contract address from validators
    {
      const result = await stakeManager.validators("validatorAddress");
      cs = CommissionShare__factory.connect(result.commissionShare, wallet);
    }

    // approve for stake manager
    {
      const tx = await cs.approve(
        "0x0000000000000000000000000000000000001001",
        "approveAmount"
      );
      await tx.wait();
    }

    // start unstake
    {
      const tx = await stakeManager.startUnstake(
        "validatorAddress",
        "receiveAddress",
        "numberOfShares"
      );
      await tx.wait();
      const receipt = await provider.getTransactionReceipt(tx.hash);
      for (const log of receipt.logs) {
        if (
          log.address === "0x0000000000000000000000000000000000001001" &&
          log.topics[0] ===
            "0x020b3ba91672f551cfd1f7abf4794b3fb292f61fd70ffd5a34a60cdd04078e50" // StartUnstake event topic
        ) {
          const bn = BigNumber.from(log.topics[1]);
          console.log("your unstakeId is:", bn.toNumber());
          break;
        }
      }
    }
  } catch (err) {
    // ...
  }
})();
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Note: There will be a **vesting period** after unvote/unstake, find the pending unstake record in \`Pending Unstake\` Dashboard
{% endhint %}

### Claim Vested Stake

{% tabs %}
{% tab title="UI" %}
You can find unstake list in `Pending Unstaked` Dashboard.

Once the vesting period is completed, the `UNSTAKE` button will be enabled and you can then claim your staked tokens to your wallet now.

![](/files/uKb1IJ2iMbdqRNdUQgDr)
{% endtab %}

{% tab title="Ethers" %}

```typescript
import { getDefaultProvider, Wallet } from "ethers";
import { StakeManager__factory } from "@gxchain2/contracts";

const wallet = new Wallet(
  "yourPrivKey",
  getDefaultProvider("https://rpc-mainnet.rei.network")
);

const stakeManager = StakeManager__factory.connect(
  "0x0000000000000000000000000000000000001001",
  wallet
);

stakeManager
  .unstake("unstakeId")
  .then(() => {
    // ...
  })
  .catch((err) => {
    // ...
  });
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rei.network/rei-dao/guides/voting-for-a-validator.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
