NextKey
Storage Plain v361 → currentThe ML-KEM-768 public key that will become CurrentKey in the following block .
Explore chainThe Big Picture
When you want MEV protection for your transaction, you encrypt with NextKey. This key was announced by the upcoming block's author BEFORE they can see your encrypted submission. This ordering prevents them from choosing a key that only decrypts transactions they want to include.
Why This Matters
This is THE key you use for MEV protection. Fetch it, encrypt your transaction with it, then submit via submit_encrypted. The next block author will decrypt and execute your transaction.
Example Scenario
You want to stake 1000 TAO with MEV protection. Step 1: Query NextKey. Step 2: Encrypt your add_stake transaction with this key using ML-KEM + XChaCha20. Step 3: Call submit_encrypted with the ciphertext. Your stake is now MEV-protected.
Common Questions
- Why not use CurrentKey?
- CurrentKey is for the block being built NOW. Your submission goes into the NEXT block. Using CurrentKey would fail because that block author can't decrypt it (different key epoch).
- What if NextKey changes while I'm encrypting?
- Race condition - your encryption might use an old key. Always fetch NextKey immediately before encryption and submit quickly. If you see KeyExpired error, refetch and retry.
- How often does NextKey change?
- Every block. Each new block author announces their key for the following block. So NextKey updates roughly every 12 seconds (Bittensor block time).
Use Cases
- Encrypt transactions for MEV protection
- Build real-time MEV protection interfaces
- Monitor key rotation for MEV protection availability
From Chain Metadata
Next ML‑KEM‑768 public key bytes, announced by the block author.
Purpose & Usage
Purpose
Provides the encryption key users should use for new encrypted submissions.
Common Query Patterns
- Query to get next block's encryption key
- Fetch before encrypting new submissions
Notes
- ML-KEM-768 public key bytes
- Announced by next block's author via announce_next_key
- None if no key announced yet for next block
- Fetch fresh before each encryption to avoid KeyExpired errors
Stored Value
value (BoundedVec)
Relationships
Modified By
Code Examples
import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";
const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });
// Query NextKey storage (no keys - plain value)
const result = await api.query
[stringCamelCase("MevShield")]
[stringCamelCase("NextKey")]();
console.log("NextKey:", result.toHuman());On-Chain Activity
100K–1M estimated writes
#41 most written storage item
Modified via user-submitted extrinsics
As of block 7,429,232
Runtime Info
View Source- Pallet
- MevShield
- Storage Kind
- Plain
- First Version
- v361
- Current Version
- v393