> ## Documentation Index
> Fetch the complete documentation index at: https://primev-24-evan-kim2028-patch-1.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Stake Validators Keys Manually

## Staking with registry

The [validator registry contract](https://holesky.etherscan.io/address/0x5d4fC7B5Aeea4CF4F0Ca6Be09A2F5AaDAd2F2803) is deployed to Holesky at address `0x5d4fC7B5Aeea4CF4F0Ca6Be09A2F5AaDAd2F2803`, with a minimum stake requirement of 0.0001 ETH, and a 96 block unstaking period. This unstaking period corresponds to 19.2 minutes, assuming a 12 sec Holesky block time. This period allows two L1 epochs (L1 finalization period) plus a settlement buffer, to pass between validator unstake initiation and withdrawal.

The registry strictly accepts BLS public keys as the validator opt-in identifier. Any EOA can stake on behalf of a validator pub key, and only that EOA has the ability to withdraw in the future.

To stake with the mev-commit validator registry, first use an available Holesky faucet to fund an account.

To `stake` with the contract, see the following function signature, where ether sent with the transaction is split evenly among the specified validator pub keys:

```solidity
function stake(bytes[] calldata validatorBLSPubKeys) external payable {
    uint256 splitAmount = msg.value / validatorBLSPubKeys.length;
    for (uint256 i = 0; i < validatorBLSPubKeys.length; i++) {
        stakedBalances[validatorBLSPubKeys[i]] += splitAmount;
    }
}
```

<Note> Due to gas limitations, it is recommended to stake in batches of 10-20 public keys at a time to ensure transaction success without hitting gas limits. </Note>

### Using Golang

You can programmatically interact with the validator registry using [Golang scripts](https://github.com/primev/validator-registry).
To stake one or more validator BLS public keys, refer to [this example script](https://github.com/primev/validator-registry/blob/main/cmd/stake/main.go) as outlined in the steps below:

<Steps>
  <Step title="Clone the Repository">
    Clone the validator-registry repository using the following command:

    ```bash ❯_ terminal
    git clone https://github.com/primev/validator-registry.git
    ```
  </Step>

  <Step title="Prepare Validator Keys">
    Change directory into the cloned repository and edit the `keys_example.txt` file to include your validator BLS public keys:

    ```bash ❯_ terminal
    cd validator-registry
    vi keys_example.txt
    *Edit file as needed*
    ```
  </Step>

  <Step title="Run the Stake Script">
    Navigate to the `cmd/stake` directory and run the staking script with your funded private key:

    ```bash ❯_ terminal
    cd cmd/stake
    PRIVATE_KEY="0x..." go run main.go
    ```

    This script will attempt to stake `3.1` ETH on behalf of each validator BLS public key in `keys_example.txt`.
  </Step>
</Steps>

*Note these scripts are not actively maintained and should only be used as a starting point for staking validator pub keys manually.*

## Withdrawing

To withdraw your staked ether, you have two options: through the validator registry interface or programmatically using a Golang script.
Please be aware that an unstaking period is mandatory. You must initiate an `unstake` transaction and wait for the required number of
blocks to pass before you can execute a `withdraw` transaction to transfer the funds to your account.
