keymake_withdrawal_credentials

Generate ETH1 withdrawal credentials for validator deposits

Build 32-byte ETH1 withdrawal credentials from an Ethereum address.

Overview

make_withdrawal_credentials() generates the 32-byte withdrawal credentials required for validator deposits. These credentials determine which Ethereum address can withdraw a validator's funds when they exit the validator set.

The function creates ETH1-style withdrawal credentials with the format: 0x01 + 11 zero bytes + 20-byte Ethereum address.

Signature

def make_withdrawal_credentials(address: str) -> bytes

Import

from seismic_web3 import make_withdrawal_credentials

Parameters

Parameter
Type
Required
Description

address

str

Yes

Hex-encoded Ethereum address (with or without 0x prefix)

Returns

Type
Description

bytes

32-byte withdrawal credentials in ETH1 format

Examples

Basic Usage

With and Without 0x Prefix

Complete Deposit Flow

Using Separate Withdrawal Address

Checksum Addresses

Verifying Credentials Format

How It Works

The function constructs withdrawal credentials using the ETH1 format:

Breakdown:

  1. Type byte (0x01): Indicates ETH1-style withdrawal credentials

  2. Padding (11 bytes of 0x00): Reserved space

  3. Address (20 bytes): Ethereum address that can withdraw funds

Example:

Credential Types

Ethereum supports two types of withdrawal credentials:

ETH1 Withdrawal (0x01)

  • Type byte: 0x01

  • Format: 0x01 + 11 zero bytes + 20-byte address

  • Created by: make_withdrawal_credentials()

  • Withdrawals: Direct to Ethereum address

  • Best for: Most validators (simple and direct)

BLS Withdrawal (0x00)

  • Type byte: 0x00

  • Format: 0x00 + 31-byte BLS pubkey hash

  • Created by: Custom (not provided by this function)

  • Withdrawals: Requires BLS signature

  • Best for: Advanced setups (e.g., multi-sig validators)

This function only creates ETH1 credentials (0x01).

Error Handling

Common Errors

Validation

The function validates:

  • Address must decode to exactly 20 bytes

  • Hex string must be valid (0-9, a-f, A-F)

  • Length check after removing 0x prefix

The function does NOT validate:

  • Checksum correctness (EIP-55)

  • Whether address exists on-chain

  • Whether address is a contract or EOA

Security Considerations

Choose Withdrawal Address Carefully

The withdrawal address controls validator withdrawals:

Once set, withdrawal credentials typically cannot be changed.

Use a secure cold wallet address for withdrawals:

Multi-Sig Considerations

Consider using a multi-sig wallet for high-value validators:

Verify Before Depositing

Always double-check withdrawal credentials before depositing:

Common Use Cases

Standard Validator Setup

Staking Service

Validator Pool

Alternative: BLS Withdrawal Credentials

If you need BLS-style credentials (type 0x00), implement manually:

When to Use

Use make_withdrawal_credentials() when:

  • Making a validator deposit

  • Generating ETH1 withdrawal credentials

  • Building validator onboarding tools

  • Implementing staking services

  • Creating deposit data for testing

Deposit Flow

See Also

Last updated