# Staking V2 (/docs/guides/evm/precompiles/staking-v2)

| Property            | Value                                        |
| ------------------- | -------------------------------------------- |
| Rust implementation | `StakingPrecompileV2`                        |
| Solidity interface  | `IStaking` V2                                |
| Address             | `0x0000000000000000000000000000000000000805` |
| Status              | Deployed                                     |

This is the current staking interface. The V1 address remains available for
backward compatibility.

## Stake operations [#stake-operations]

```text
addStake(bytes32,uint256,uint256)
addStakeLimit(bytes32,uint256,uint256,bool,uint256)
removeStake(bytes32,uint256,uint256)
removeStakeLimit(bytes32,uint256,uint256,bool,uint256)
removeStakeFull(bytes32,uint256)
removeStakeFullLimit(bytes32,uint256,uint256)
moveStake(bytes32,bytes32,uint256,uint256,uint256)
transferStake(bytes32,bytes32,uint256,uint256,uint256)
burnAlpha(bytes32,uint256,uint256)
```

These functions are `payable`.

## Stake views [#stake-views]

```text
getStake(bytes32,bytes32,uint256)
getStakeInfoForColdkeyAndNetuid(bytes32,uint256,bytes32[])
getTotalColdkeyStake(bytes32)
getTotalColdkeyStakeOnSubnet(bytes32,uint256)
getTotalHotkeyStake(bytes32)
getAlphaStakedValidators(bytes32,uint256)
getTotalAlphaStaked(bytes32,uint256)
getNominatorMinRequiredStake()
getDefaultMinStake()
```

These functions are `view`.

## Relationship and ownership views [#relationship-and-ownership-views]

```text
getDelegate(bytes32)
getChildkeyTake(bytes32,uint16)
getPendingChildKeys(bytes32,uint16)
getChildKeys(bytes32,uint16)
getParentKeys(bytes32,uint16)
getPendingChildKeyCooldown()
getTakeLimits()
getMinChildkeyTakePerSubnet(uint16)
getHotkeyOwner(bytes32)
getOwnedHotkeys(bytes32)
getAutoStakeDestination(bytes32,uint16)
getAutoStakeDestinationColdkeys(bytes32,uint16)
getHotkeySuccessor(bytes32,uint16)
getHotkeyRoot(bytes32,uint16)
getColdkeySuccessor(bytes32)
getColdkeyRoot(bytes32)
getColdkeySwapStatus(bytes32)
getColdkeySwapDelays()
getLastHotkeySwapOnSubnet(bytes32,uint16)
```

Optional relationships return an explicit `exists` flag. Child and parent
links return typed `(proportion, account)` entries.

## Accounting and collateral views [#accounting-and-collateral-views]

```text
getStakeAccounting()
getMinerCollateral(uint16,bytes32,bytes32)
getColdkeyCollateral(uint16,bytes32)
getCollateralConfig(uint16)
```

Fixed-point collateral ratios are returned as their raw `U64F64` bits.

## Locks and account policy [#locks-and-account-policy]

```text
lockStake(bytes32,uint256,uint256)
moveLock(bytes32,uint256)
setPerpetualLock(uint256,bool)
setRejectLockedAlpha(bool)
getColdkeyLock(bytes32,uint256)
getHotkeyLock(bytes32,uint256)
getHotkeyConvictions(uint256,bytes32[])
getLockRates()
getRejectLockedAlpha(bytes32)
```

The `get` functions are `view`; the other functions are `payable`.

## Proxies and stake allowances [#proxies-and-stake-allowances]

```text
addProxy(bytes32)
removeProxy(bytes32)
approve(address,uint256,uint256)
allowance(address,address,uint256)
increaseAllowance(address,uint256,uint256)
decreaseAllowance(address,uint256,uint256)
transferStakeFrom(address,address,bytes32,uint256,uint256,uint256)
```

`allowance` is `view`. Refer to the published ABI for the mutability and return
encoding of the allowance mutations.

## Added Subtensor operations [#added-subtensor-operations]

| Function                         | Source extrinsic                                     |
| -------------------------------- | ---------------------------------------------------- |
| `decreaseTake`                   | `SubtensorModule.decrease_take`                      |
| `increaseTake`                   | `SubtensorModule.increase_take`                      |
| `setChildkeyTake`                | `SubtensorModule.set_childkey_take`                  |
| `unstakeAll`                     | `SubtensorModule.unstake_all`                        |
| `unstakeAllAlpha`                | `SubtensorModule.unstake_all_alpha`                  |
| `swapStake`                      | `SubtensorModule.swap_stake`                         |
| `swapStakeLimit`                 | `SubtensorModule.swap_stake_limit`                   |
| `recycleAlpha`                   | `SubtensorModule.recycle_alpha`                      |
| `setColdkeyAutoStakeHotkey`      | `SubtensorModule.set_coldkey_auto_stake_hotkey`      |
| `claimRoot`                      | `SubtensorModule.claim_root`                         |
| `claimRootWithHotkey`            | `SubtensorModule.claim_root_with_hotkey`             |
| `setRootClaimThreshold`          | `SubtensorModule.sudo_set_root_claim_threshold`      |
| `addStakeBurn`                   | `SubtensorModule.add_stake_burn`                     |
| `setAutoParentDelegationEnabled` | `SubtensorModule.set_auto_parent_delegation_enabled` |
| `transferStakeAndHotkey`         | `SubtensorModule.transfer_stake_and_hotkey`          |
| `addCollateral`                  | `SubtensorModule.add_collateral`                     |
| `setMinCollateral`               | `SubtensorModule.set_min_collateral`                 |

`recycleAlpha` is distinct from deployed `burnAlpha`: recycling reduces
`SubnetAlphaOut` and Alpha issuance, while burning does not reduce
`SubnetAlphaOut`.

`claimRoot` redeems every validator basket for the mapped caller. Its subnet
array is retained by the runtime for old call-data compatibility and is
ignored. `claimRootWithHotkey` redeems only the specified validator basket.

## Root claim views [#root-claim-views]

```text
getUnclaimedRootTaoByHotkey(bytes32,bytes32)
getUnclaimedRootTaoBySubnet(bytes32,uint16,bytes32[])
```

Both views return realizable TAO in 18-decimal EVM units.
`getUnclaimedRootTaoBySubnet` accepts at most 64 distinct validator hotkeys per
call. For coldkeys with more validators, sum the results from multiple
caller-supplied batches. This keeps every contract read bounded without
decoding the coldkey's potentially unbounded historical hotkey list.

## Added AdminUtils operations [#added-adminutils-operations]

| Function                      | Source extrinsic                                   |
| ----------------------------- | -------------------------------------------------- |
| `setMinChildkeyTakePerSubnet` | `AdminUtils.sudo_set_min_childkey_take_per_subnet` |
| `setCollateralLockShare`      | `AdminUtils.sudo_set_collateral_lock_share`        |
| `setCollateralDrainRatio`     | `AdminUtils.sudo_set_collateral_drain_ratio`       |

The listed owner-or-Root calls expose only their signed subnet-owner path.
Every operation dispatches the highest-level extrinsic as the mapped caller so
runtime authorization remains in force.

## Proposed bulk runtime API [#proposed-bulk-runtime-api]

`DelegateInfoRuntimeApi.get_delegates` remains proposed. Its current result can
grow with chain state, so no Solidity selector is assigned in this change.
Before implementation, it needs a bounded cursor-based or indexed interface
whose stable return type is independent of the runtime's SCALE representation.

Source: [`stakingV2.sol`](https://github.com/RaoFoundation/subtensor/blob/main/precompiles/src/solidity/stakingV2.sol)
