# 🔏How to Stake TAN?

Learn how to stake TAN and set up a validator node on the TAN blockchain network to participate in transaction validation and network security.

## Staking TAN to Become a Validator <a href="#staking-taral-to-become-a-validator" id="staking-taral-to-become-a-validator"></a>

Validator nodes are essential components of the TAN blockchain network. They validate transactions and propose new blocks, contributing directly to the consensus mechanism. Becoming a validator requires a commitment to maintaining high uptime and adhering to network protocols.

## How to Stake TAN <a href="#staking-taral-to-become-a-validator" id="staking-taral-to-become-a-validator"></a>

**Prerequisite:** Before proceeding with the staking contracts, ensure you have a fully synchronized full node running in the current blockchain state of TAN.

**Step 1: Clone the Repository from** [**GitHub**](https://github.com/0xPolygon/staking-contracts/tree/main)**.**

**Step 2: Open cloned repository in terminal and install dependencies navigate to the cloned `staking-contracts` directory from the `main` branch and run `npm i` to install dependencies.**

**Step 3: Execute the following command to copy the example environment file to `.env`:**

```
cp .env.example .env   
```

**Step 4 : Use the following command to open and edit the `.env` file using the Nano text editor :**

```
nano .env
```

**Step 5: Replace the existing content in your `.env` file with the following configuration details:**

```
JSONRPC_URL= <Use Tan RPC URL>
PRIVATE_KEYS= <Your private key of wallet which was initially generated at the time of key pair>
STAKING_CONTRACT_ADDRESS= 0x0000000000000000000000000000000000001001
BLS_PUBLIC_KEY= <Your BLS_Public_key which was initially generated at the time of key pair>
```

Save the updated `.env` file after replacing the placeholders with your actual configuration details.

**Step 6: Retrieve Private Key for Staking.**

Change directory to the location where your private key file (`validator.key`) is stored.

```
cd <yourkeygeneratedDirectory>/consensus
```

Use the following command to display the content of the `validator.key` file, which contains your private key:

```
cat validator.key
```

Copy the private key displayed in your terminal. This private key is needed for configuring your staking setup in the `.env` file.

**Step 7: You must have 20000 TAN in your wallet.**

Execute the following curl command in your terminal to check the balance of your wallet address:

```
curl --location 'https://devnet-rpc1.tanledger.com' \
--header 'Content-Type: application/json' \
--data '{"method":"eth_getBalance","params":["<YOUR WALLET ADDRESS>", "latest"],"id":1,"jsonrpc":"2.0"}'
```

Replace `<YOUR WALLET ADDRESS>` with your actual wallet address where you want to check the balance. Ensure your wallet contains at least 20000 TAN. If the balance is insufficient, please add TAN to your wallet.

**Step 8: Build the Project Using npm**

Execute the following command to build the project using npm:

```
npm run build
```

**Step 9: Run the Stake Command:**

Execute the following command to initiate the stake process using npm:

```
npm run stake
```

You should receive a confirmation message indicating that you have staked TAN successfully.

## Conclusion

In this guide, you've learned how to set up and stake TAN tokens to become a validator on the TAN blockchain network. By following these steps, you've configured your environment, managed your wallet, and interacted with staking contracts to contribute to network security and transaction validation. Staking TAN tokens not only helps secure the network but also allows you to participate actively in the decentralized consensus process. Ensure to monitor your validator node and manage rewards effectively to maximize your participation in the TAN ecosystem.


---

# 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.tan.live/getting-started/developer-guide/nodes-and-validators/how-to-stake-tan.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.
