Get Zone Encryption Key
zone.getEncryptionKey
Returns the active sequencer encryption key for a zone.
Usage
import { } from './viem.config'
const { , } = await ..({
: 7,
})
.('Key index:', )
.('Public key:', )
Key index: 0nPublic key: { prefix: 3, x: '0x57e8a1e347b0c8e8c14290499e1281f84eae5d1cdd10cc5eb4d92aca17c5c1d4' }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Detect Key Rotation Before Submitting a Prepared Deposit
Compare a prepared payload's keyIndex with the current key before broadcasting, and re-encrypt with zone.encryptedDeposit's prepare if the sequencer rotated keys.
import { } from 'viem/tempo'
import { } from './viem.config'
const = {
: 100_000_000n,
: '0x8ba1f109551bD432803012645Ac136ddd64DBA72',
: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
: '0x20c0000000000000000000000000000000000001',
: 7,
} as
let = await ...(, )
// Re-check the key once the batching window closes.
const { } = await ..({ : 7 })
if ( !== .)
= await ...(, )
const = await ..()import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Type
type ReturnType = {
/** Zero-based encryption key index. */
keyIndex: bigint
/** Active sequencer encryption public key. */
publicKey: {
/** SEC1 compressed public key prefix. */
prefix: 2 | 3
/** Public key x-coordinate. */
x: Hex
}
}The active encryption key and its zero-based index.
Parameters
blockNumber (optional)
- Type:
bigint
Block number to read the state from.
blockTag (optional)
- Type:
BlockTag - Default:
'latest'
Block tag to read the state from.
portalAddress (optional)
- Type:
Address - Default: the configured portal registry
Zone portal address.
stateOverride (optional)
- Type:
StateOverride
State override to apply.
zoneId
- Type:
number
Zone ID.