### Example Head Event Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md This is an example of a 'head' event, which is emitted when a new block is added to the chain tip. ```json event: head data: { "slot": "1000", "block": "0xcf8e0d4e...", "state": "0x9c2d...", "epoch_transition": false, "previous_duty_dependent_root": "0x...", "current_duty_dependent_root": "0x..." } ``` -------------------------------- ### Light Client Bootstrap Response Example Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Example JSON response for light client bootstrap data. Used for light client initialization. ```json { "version": "gloas", "data": { "header": {...}, "current_sync_committee": {...}, "current_sync_committee_branch": [...] } } ``` -------------------------------- ### Light Client Updates Response Example Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Example JSON response structure for light client updates. Requires 'start_period' and 'count' query parameters. ```json { "data": [...] } ``` -------------------------------- ### Beacon Chain Fork Schedule Response Example Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Example JSON response from the `/eth/v1/config/fork_schedule` endpoint, showing the version and epoch for each fork. ```json { "data": [ { "version": "0x00000000", "epoch": "0" }, { "version": "0x01000000", "epoch": "74240" }, ... ] } ``` -------------------------------- ### Beacon Chain Event Examples Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Examples of Server-Sent Events (SSE) for 'head' and 'finalized_checkpoint' topics. Ensure exponential backoff for reconnection. ```text event: head data: {"slot":"1","block":"0x...","state":"0x...","epoch_transition":false,"previous_duty_dependent_root":"0x...","current_duty_dependent_root":"0x..."} event: finalized_checkpoint data: {"block":"0x...","state":"0x...","epoch":"0"} ``` -------------------------------- ### Example Finalized Checkpoint Event Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md This is an example of a 'finalized_checkpoint' event, emitted when an epoch is finalized by the fork choice. ```json event: finalized_checkpoint data: { "block": "0xcf8e0d4e...", "state": "0x...", "epoch": "100" } ``` -------------------------------- ### Install and Run Redocly CLI for Linting Source: https://github.com/ethereum/beacon-apis/blob/master/README.md Install the Redocly CLI globally using npm or yarn to lint the beacon node OpenAPI specification file. Run the lint command to check for errors. ```bash npm install -g @redocly/cli ``` ```bash yarn global add @redocly/cli ``` ```bash redocly lint beacon-node-oapi.yaml ``` -------------------------------- ### Deposit Contract Info Response Example Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Example JSON response from the `/eth/v1/config/deposit_contract` endpoint, detailing the deposit contract's chain ID and address. ```json { "data": { "chain_id": "1", "address": "0x00000000219ab540356cbb839cbe05303d7705fa" } } ``` -------------------------------- ### GET /eth/v1/beacon/light_client/bootstrap/{block_root} Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Get bootstrap data for light client initialization. This endpoint is used to obtain the necessary information to initialize a light client from a specific block root. ```APIDOC ## GET /eth/v1/beacon/light_client/bootstrap/{block_root} ### Description Get bootstrap data for light client initialization. This endpoint is used to obtain the necessary information to initialize a light client from a specific block root. ### Method GET ### Endpoint /eth/v1/beacon/light_client/bootstrap/{block_root} ### Parameters #### Path Parameters - **block_root** (Root) - Required - Block root to initialize from ### Request Example (No explicit request body example provided) ### Response #### Success Response (200) - **version** (string) - - **data** (object) - - **header** (object) - - **current_sync_committee** (object) - - **current_sync_committee_branch** (array) - #### Response Example ```json { "version": "gloas", "data": { "header": {...}, "current_sync_committee": {...}, "current_sync_committee_branch": [...] } } ``` ### Error Responses - `400`: Invalid block_root - `404`: Block not found - `500`: Internal Server Error ``` -------------------------------- ### Validator Implementation Guide Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/ANALYSIS_SUMMARY.txt A guide for implementing validator clients, including complete technical flows, endpoint sequences, and signature requirements. Generated from validator-reference.md. ```APIDOC ## Validator Implementation Guide This guide provides complete technical flows for implementing validator clients. It outlines the necessary endpoint sequences and signature requirements for various validator operations. ### Example Flow Step: 1. **Submit Attestation**: Use the `POST /eth/v1/validator/attestations` endpoint to submit validator attestations. - **Request Body**: Requires `attestations` and `sync_committee_attestations` fields. - **Signature**: Ensure the request is correctly signed according to the specification. Refer to the `validator-reference.md` file for complete flows and endpoint sequences. ``` -------------------------------- ### Get Proposer Duties Response (v1) Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Example JSON response for the v1 proposer duties request, detailing the slot and validator index for block proposals. ```json { "data": [ { "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "validator_index": "0", "slot": "3200" } ], "dependent_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", "execution_optimistic": false } ``` -------------------------------- ### Light Client Finality Update Response Example Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Example JSON response for the latest light client finality update. Includes attested and finalized headers, and sync aggregate data. ```json { "version": "gloas", "data": { "attested_header": {...}, "finalized_header": {...}, "finality_branch": [...], "sync_aggregate": {...}, "signature_slot": "1" } } ``` -------------------------------- ### Example Error Response for Block Publishing Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md An example of an error response when publishing a block, indicating an invalid block due to a missing signature. ```json { "code": 400, "message": "Invalid block: missing signature" } ``` -------------------------------- ### GET /eth/v3/validator/blocks/{slot} Response Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Example response for successfully producing a block for a given slot. This includes block details like slot, proposer index, parent root, state root, and body. ```json { "version": "gloas", "data": { "slot": "1", "proposer_index": "0", "parent_root": "0x...", "state_root": "0x...", "body": {...} } } ``` -------------------------------- ### Query Validator by Public Key Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Example of querying a specific validator using its BLS public key. ```bash curl "http://localhost:5052/eth/v1/beacon/states/head/validators/0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a" ``` -------------------------------- ### Query Validator by Index Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Example of querying a specific validator using its decimal index. ```bash curl "http://localhost:5052/eth/v1/beacon/states/head/validators/0" ``` -------------------------------- ### PTC Duties Response Example Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Example JSON response for the PTC duties endpoint. Key fields include the validator index and the slot where PTC duties apply. ```json { "data": [ { "validator_index": "0", "slot": "11866112" } ], "execution_optimistic": false } ``` -------------------------------- ### Validator Client Implementation Guide Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/ANALYSIS_SUMMARY.txt This section details the sequences and flows for validator client operations, including block proposal and attestation. ```APIDOC ## Validator Client Operations ### Description Guides for implementing validator clients, covering lifecycle, block proposal, and attestation sequences. ### Block Proposal Sequence 1. Proposer duties 2. Block production 3. Block publication 4. Signature generation ### Attestation Sequence 1. Attester duties 2. Committee subscription 3. Attestation data 4. Construction and broadcast 5. Aggregation (if aggregator) ### Other Flows - Sync committee flow (Altair+) - PTC flow (Gloas+) - Validator registration and fee recipient - Execution payload flow (builders) ### Error Handling - Reference `errors.md` for detailed error handling strategies. ``` -------------------------------- ### GET /eth/v1/node/version Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Retrieves the version information of the Beacon Node client. ```APIDOC ## GET /eth/v1/node/version ### Description Retrieve node version information. ### Method GET ### Endpoint /eth/v1/node/version ### Response #### Success Response (200) - **data** (object) - **version** (string) - Client implementation and version string ### Response Example ```json { "data": { "version": "Lighthouse/v1.0.0 (Linux x86_64)" } } ``` ``` -------------------------------- ### Query Multiple Validators Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Example of querying multiple validators by providing an array of mixed indices and public keys in the request body. ```bash curl -X POST http://localhost:5052/eth/v1/beacon/states/head/validators \ -d '{"ids":["0", "1", "0x93247f..."]}' ``` -------------------------------- ### Get Chain Specification Parameters Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Retrieve all specification parameters for the chain. This is useful for understanding the current network configuration. ```json { "data": { "PRESET_BASE": "mainnet", "CONFIG_NAME": "mainnet", "GENESIS_FORK_VERSION": "0x00000000", "GENESIS_VALIDATORS_ROOT": "0x...", "...": "..." } } ``` -------------------------------- ### Query Block by Identifier Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Examples of querying blocks using different identifiers like 'head', 'finalized', slot numbers, or block roots. ```bash curl http://localhost:5052/eth/v2/beacon/blocks/head ``` ```bash curl http://localhost:5052/eth/v2/beacon/blocks/finalized ``` ```bash curl http://localhost:5052/eth/v2/beacon/blocks/1000 ``` ```bash curl http://localhost:5052/eth/v2/beacon/blocks/0x.../attestations ``` -------------------------------- ### Retrieve Proposer Duties Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Fetches the duties for validators at the start of an epoch. This is the first step in the block proposal process. ```python epoch = current_epoch() duties = beacon_node.get_proposer_duties(epoch) proposals = {d['slot']: d for d in duties['data'] if d['validator_index'] in managed_validators} ``` -------------------------------- ### Get Attestation Rewards Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Retrieves attestation rewards for specified validators in an epoch. Requires a list of validator indices. ```bash curl -X POST http://localhost:5052/eth/v1/beacon/rewards/attestations/100 \ -H "Content-Type: application/json" \ -d '["0", "1"]' ``` -------------------------------- ### GET /eth/v1/beacon/genesis Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Retrieves the genesis details of the Ethereum Beacon chain, including the genesis time, validators root, and fork version. ```APIDOC ## GET /eth/v1/beacon/genesis ### Description Retrieve details of the chain's genesis. ### Method GET ### Endpoint /eth/v1/beacon/genesis ### Parameters None ### Response #### Success Response (200) - **genesis_time** (Uint64) - Unix timestamp in seconds at which the chain began - **genesis_validators_root** (Root) - Root hash of the genesis validators tree (32-byte hex string) - **genesis_fork_version** (ForkVersion) - 4-byte hex string identifying the genesis fork #### Response Example ```json { "data": { "genesis_time": "1590832934", "genesis_validators_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", "genesis_fork_version": "0x00000000" } } ``` ``` -------------------------------- ### Retrieve Deposit Contract Information Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Use the `/eth/v1/config/deposit_contract` endpoint to get information about the deposit contract, including its chain ID and address. ```bash curl http://localhost:5052/eth/v1/config/deposit_contract ``` -------------------------------- ### GET /eth/v2/validator/aggregate_attestation Response Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Example response for successfully retrieving an aggregated attestation. This is used to get an aggregated attestation for a specific slot and committee. ```json { "version": "gloas", "data": { "aggregation_bits": "0x...", "data": {...}, "signature": "0x..." } } ``` -------------------------------- ### GET /eth/v1/beacon/light_client/updates Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Get light client updates. This endpoint retrieves a series of updates for the light client, specified by a starting period and a count. ```APIDOC ## GET /eth/v1/beacon/light_client/updates ### Description Get light client updates. This endpoint retrieves a series of updates for the light client, specified by a starting period and a count. ### Method GET ### Endpoint /eth/v1/beacon/light_client/updates ### Parameters #### Query Parameters - **start_period** (Uint64) - Required - Start sync committee period - **count** (Uint64) - Required - Maximum number of updates to return ### Request Example (No explicit request body example provided) ### Response #### Success Response (200) - **data** (array) - #### Response Example ```json { "data": [...] } ``` ### Error Responses - `400`: Invalid parameters - `500`: Internal Server Error ``` -------------------------------- ### GET /eth/v2/node/version Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Retrieves the version information of the Beacon Node client, including additional metadata like implementation and version number. ```APIDOC ## GET /eth/v2/node/version ### Description Retrieve node version information with additional metadata (v2). ### Method GET ### Endpoint /eth/v2/node/version ### Response #### Success Response (200) - **data** (object) - **version** (string) - Client implementation and version string - **implementation** (string) - Client implementation name - **version_number** (string) - Client version number ### Response Example ```json { "data": { "version": "Lighthouse/v1.0.0 (Linux x86_64)", "implementation": "Lighthouse", "version_number": "1.0.0" } } ``` ``` -------------------------------- ### GET /eth/v1/beacon/execution_payload_envelopes/{block_id} Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Retrieves the execution payload envelope for a specific block, starting from the Gloas fork. This is useful for inspecting block details. ```APIDOC ## GET /eth/v1/beacon/execution_payload_envelopes/{block_id} ### Description Get execution payload envelope for a block (Gloas fork onwards). ### Method GET ### Endpoint /eth/v1/beacon/execution_payload_envelopes/{block_id} ### Parameters #### Path Parameters - **block_id** (String) - Required - Block identifier ### Response #### Success Response (200) - **data** (object) - Contains the execution payload envelope. ### Response Example { "data": {...} } ``` -------------------------------- ### Serve Beacon API Spec Locally (Node.js) Source: https://github.com/ethereum/beacon-apis/blob/master/README.md Use these commands to install and run a simple HTTP server for rendering the API specification locally. Access the rendered spec at http://localhost:8000. ```bash npm install simplehttpserver -g ``` ```bash yarn global add simplehttpserver ``` ```bash simplehttpserver ``` -------------------------------- ### GET /eth/v3/validator/blocks/{slot} Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Produces a block for a given slot, starting from the Gloas fork. This endpoint is used by validators to generate new blocks. ```APIDOC ## GET /eth/v3/validator/blocks/{slot} ### Description Produce a block for a given slot (Gloas fork onwards). ### Method GET ### Endpoint /eth/v3/validator/blocks/{slot} ### Parameters #### Path Parameters - **slot** (Uint64) - Required - Slot for which to produce block #### Query Parameters - **randao_reveal** (Signature) - Required - Signed RANDAO reveal - **graffiti** (Graffiti) - Optional - Graffiti string (32 bytes max) - **skip_randao_verification** (Boolean) - Optional - Skip RANDAO verification #### Request Header - **Eth-Consensus-Version** (string) - Required - Consensus version ### Response #### Success Response (200) - **version** (string) - **data** (object) - **slot** (string) - **proposer_index** (string) - **parent_root** (string) - **state_root** (string) - **body** (object) #### Response Example ```json { "version": "gloas", "data": { "slot": "1", "proposer_index": "0", "parent_root": "0x...", "state_root": "0x...", "body": {} } } ``` ``` -------------------------------- ### Get Proposer Duties Response (v2) Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Example JSON response for the v2 proposer duties request, which includes the 'is_aggregator' field in addition to v1 data. ```json { "data": [ { "pubkey": "0x...", "validator_index": "0", "slot": "3200", "is_aggregator": false } ], "dependent_root": "0x...", "execution_optimistic": false } ``` -------------------------------- ### LightClientBootstrap Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/types.md Provides bootstrap data for initializing a light client, including the block header, current sync committee, and its Merkle branch. ```APIDOC ## LightClientBootstrap ### Description Bootstrap data for initializing a light client. ### Fields - **header** (BeaconBlockHeader) - Yes - Block header - **current_sync_committee** (SyncCommittee) - Yes - Current sync committee - **current_sync_committee_branch** (Array[Root]) - Yes - Merkle branch for sync committee ``` -------------------------------- ### Get Proposer Duties Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Retrieves the duties for validators who are scheduled to propose a block in a given epoch. This is typically called at the start of an epoch to prepare for block proposals. ```APIDOC ## GET /eth/v1/validator/duties/proposer/{epoch} ### Description Retrieves the duties for validators who are scheduled to propose a block in a given epoch. This is typically called at the start of an epoch to prepare for block proposals. ### Method GET ### Endpoint `/eth/v1/validator/duties/proposer/{epoch}` ### Parameters #### Path Parameters - **epoch** (integer) - Required - The epoch for which to retrieve proposer duties. #### Query Parameters - **validator_indices** (array of strings) - Required - An array of validator indices to query. ### Request Example ```bash curl -X POST http://localhost:5052/eth/v1/validator/duties/proposer/100 \ -H "Content-Type: application/json" \ -d '["0", "1", "2"]' # Array of validator indices to query ``` ### Response #### Success Response (200) - **data** (array) - An array of proposer duty objects. - **pubkey** (string) - The public key of the validator. - **validator_index** (string) - The index of the validator. - **slot** (string) - The slot at which the validator must propose. - **is_aggregator** (boolean) - Whether the validator can aggregate attestations (v2). - **dependent_root** (string) - A root that depends on the state. - **execution_optimistic** (boolean) - Indicates if the response is execution optimistic. #### Response Example (v1) ```json { "data": [ { "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "validator_index": "0", "slot": "3200" } ], "dependent_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", "execution_optimistic": false } ``` #### Response Example (v2) ```json { "data": [ { "pubkey": "0x...", "validator_index": "0", "slot": "3200", "is_aggregator": false } ], "dependent_root": "0x...", "execution_optimistic": false } ``` ### Error Handling - `503 Service Unavailable`: Node is syncing, retry after delay. - `400 Bad Request`: Invalid epoch or validator indices. ``` -------------------------------- ### Get Attester Duties Response Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Example JSON response for the attester duties request, detailing information needed for attestation, including committee assignments and the slot for the attestation. ```json { "data": [ { "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "validator_index": "0", "committee_index": "0", "committee_length": "128", "committees_at_slot": "8", "validator_committee_index": "5", "slot": "3200" } ], "dependent_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", "execution_optimistic": false } ``` -------------------------------- ### Construct and Broadcast Attestation (Python) Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md This Python function demonstrates the process of constructing an attestation, including creating aggregation bits, signing the data, and submitting it to the beacon node. It requires helper functions for domain computation, hashing, and signing. ```python def attest(slot, committee_index, validator_index_in_committee): """Construct and broadcast attestation.""" # Get attestation data att_data = beacon_node.produce_attestation_data(slot, committee_index) # Create aggregation bits committee_size = committees[committee_index].length aggregation_bits = BitList([False] * committee_size) aggregation_bits[validator_index_in_committee] = True # Mark this validator # Sign attestation domain = compute_domain(BEACON_ATTESTER, fork, genesis_validators_root) att_hash = hash_tree_root(att_data) signature = Sign(att_hash, domain, validator_key) # Broadcast attestation attestation = { "aggregation_bits": hex(aggregation_bits), "data": att_data, "signature": hex(signature) } beacon_node.submit_attestations([attestation]) ``` -------------------------------- ### GET /eth/v1/validator/sync_committee_contribution Response Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Example response for a successful sync committee contribution. This data includes slot, beacon block root, subcommittee index, aggregation bits, and signature. ```json { "data": { "slot": "1", "beacon_block_root": "0x...", "subcommittee_index": "0", "aggregation_bits": "0x...", "signature": "0x..." } } ``` -------------------------------- ### Get PTC Duties Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Retrieves Payload Timeliness Committee (PTC) duties for a given epoch. This endpoint is available from the Gloas hard fork onwards. It should be called at the start of the epoch. ```APIDOC ## POST /eth/v1/validator/duties/ptc/{epoch} ### Description Retrieves Payload Timeliness Committee (PTC) duties for a given epoch. This endpoint is available from the Gloas hard fork onwards. It should be called at the start of the epoch. ### Method POST ### Endpoint /eth/v1/validator/duties/ptc/{epoch} ### Parameters #### Path Parameters - **epoch** (integer) - Required - The epoch for which to retrieve PTC duties. #### Request Body - **validator_indices** (array of strings) - Required - A list of validator indices. ### Request Example ```bash curl -X POST http://localhost:5052/eth/v1/validator/duties/ptc/370816 \ -H "Content-Type: application/json" \ -d '["0"]' ``` ### Response #### Success Response (200) - **data** (array) - An array of PTC duty objects. - **validator_index** (string) - The validator's index. - **slot** (string) - The slot where PTC duties apply. - **execution_optimistic** (boolean) - Indicates if the response is execution optimistic. #### Response Example ```json { "data": [ { "validator_index": "0", "slot": "11866112" } ], "execution_optimistic": false } ``` **Note**: Payload Timeliness Committee: Validators confirm execution payload/blob availability. Gloas Fork Onward Only. ``` -------------------------------- ### Get PTC Duties Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Use this endpoint to retrieve Payload Timeliness Committee (PTC) duties for a given epoch. This is applicable for the Gloas fork onwards. Call at the start of the epoch. ```bash curl -X POST http://localhost:5052/eth/v1/validator/duties/ptc/370816 \ -H "Content-Type: application/json" \ -d '["0"]' ``` -------------------------------- ### Get Sync Committee Duties Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Use this endpoint to retrieve sync committee duties for a given epoch. This is applicable for Altair fork onwards. Ensure to call this at the start of the epoch. ```bash curl -X POST http://localhost:5052/eth/v1/validator/duties/sync/100 \ -H "Content-Type: application/json" \ -d '["0", "1"]' ``` -------------------------------- ### Get Attester Duties Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Retrieves the duties for validators who are scheduled to attest to blocks in a given epoch. This is typically called at the start of an epoch to schedule attestation tasks for the subsequent epoch. ```APIDOC ## POST /eth/v1/validator/duties/attester/{epoch} ### Description Retrieves the duties for validators who are scheduled to attest to blocks in a given epoch. This is typically called at the start of an epoch to schedule attestation tasks for the subsequent epoch. ### Method POST ### Endpoint `/eth/v1/validator/duties/attester/{epoch}` ### Parameters #### Path Parameters - **epoch** (integer) - Required - The epoch for which to retrieve attester duties. #### Query Parameters - **validator_indices** (array of strings) - Required - An array of validator indices to query. ### Request Example ```bash curl -X POST http://localhost:5052/eth/v1/validator/duties/attester/100 \ -H "Content-Type: application/json" \ -d '["0", "1"]' # Validator indices ``` ### Response #### Success Response (200) - **data** (array) - An array of attester duty objects. - **pubkey** (string) - The public key of the validator. - **validator_index** (string) - The index of the validator. - **committee_index** (string) - The index of the committee within the slot. - **committee_length** (string) - The total number of validators in the assigned committee. - **committees_at_slot** (string) - The total number of committees at this slot. - **validator_committee_index** (string) - The position of the validator within its committee. - **slot** (string) - The slot at which the attestation must be made. - **dependent_root** (string) - A root that depends on the state. - **execution_optimistic** (boolean) - Indicates if the response is execution optimistic. #### Response Example ```json { "data": [ { "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "validator_index": "0", "committee_index": "0", "committee_length": "128", "committees_at_slot": "8", "validator_committee_index": "5", "slot": "3200" } ], "dependent_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", "execution_optimistic": false } ``` ### Committee Aggregation (from v2 proposer duties) - If `is_aggregator=true`, validator can aggregate attestations at 2/3 slot time. - Selection proof: `Sign(slot_signature, domain)` where `slot_signature = Sign(slot, domain)`. - Modulo check: `modulo_check(selection_proof, committee_length)` determines aggregator. ``` -------------------------------- ### Ethereum Beacon APIs - Operational Configuration Reference Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/ANALYSIS_SUMMARY.txt This section details the operational configuration and setup for the Ethereum Beacon APIs. It covers server configuration, content negotiation, consensus versions, network parameters, and other essential operational aspects. ```APIDOC ## Ethereum Beacon APIs - Operational Configuration Reference ### Description This document outlines the operational configuration and setup guidelines for the Ethereum Beacon APIs. It covers server settings, network parameters, and other essential details for running and interacting with the API. ### Server Configuration - Base URLs - Default ports ### Content Negotiation - Rules for content negotiation ### Consensus Versions and Fork Schedule - Supported consensus versions - Fork schedule details ### Network Parameters - 32+ chain spec values ### Time and Slot Calculations - Methods for calculating time and slots ### State and Block Identifiers - 4 formats for identifying states and blocks ### Validator Status Values - 9 distinct validator status values ### Query Filtering Patterns - Guidelines for filtering query results ### Event Streaming (SSE) Configuration - Configuration for Server-Sent Events streaming ### Rate Limiting Recommendations - Best practices for rate limiting ### Security Considerations - Distinction between public and private endpoints ### Data Sizes and Performance Characteristics - Information on data sizes and performance ### Health Checks and Readiness - Procedures for health checks and readiness probes ### Validator Registration and Preparation - Details on validator registration and preparation processes ``` -------------------------------- ### Get Sync Committee Duties Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Retrieves sync committee duties for a given epoch. This endpoint is available from the Altair hard fork onwards. It's recommended to call this at the start of an epoch to query for the next sync committee epoch. ```APIDOC ## POST /eth/v1/validator/duties/sync/{epoch} ### Description Retrieves sync committee duties for a given epoch. This endpoint is available from the Altair hard fork onwards. It's recommended to call this at the start of an epoch to query for the next sync committee epoch. ### Method POST ### Endpoint /eth/v1/validator/duties/sync/{epoch} ### Parameters #### Path Parameters - **epoch** (integer) - Required - The epoch for which to retrieve sync committee duties. #### Request Body - **validator_indices** (array of strings) - Required - A list of validator indices. ### Request Example ```bash curl -X POST http://localhost:5052/eth/v1/validator/duties/sync/100 \ -H "Content-Type: application/json" \ -d '["0", "1"]' ``` ### Response #### Success Response (200) - **data** (array) - An array of sync committee duty objects. - **pubkey** (string) - The validator's public key. - **validator_index** (string) - The validator's index. - **validator_sync_committee_index** (string) - The validator's position within the sync committee (0-511). - **execution_optimistic** (boolean) - Indicates if the response is execution optimistic. #### Response Example ```json { "data": [ { "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "validator_index": "0", "validator_sync_committee_index": "42" } ], "execution_optimistic": false } ``` ``` -------------------------------- ### Readiness Check Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Checks if the node is ready to serve requests. Returns different status codes based on the node's readiness and sync status. ```APIDOC ## GET /eth/v1/node/health ### Description Checks the readiness of the Beacon Node to serve requests. ### Method GET ### Endpoint /eth/v1/node/health ### Parameters None ### Responses #### Success Response (200) Node is ready to serve requests. #### Status Response (206) Node is syncing and may have delayed responses. #### Error Response (503) Node is not ready (e.g., initializing, syncing from genesis). ``` -------------------------------- ### Configure Swagger UI for Beacon API Source: https://github.com/ethereum/beacon-apis/blob/master/index.html Initializes Swagger UI with multiple versions of the Beacon Node OpenAPI specification. Ensure the paths to the OpenAPI JSON/YAML files are correct. ```javascript window.onload = function() { const ui = SwaggerUIBundle({ urls: [ {url: "./releases/v4.0.0/beacon-node-oapi.json", name: "v4.0.0"}, {url: "./releases/v3.1.0/beacon-node-oapi.json", name: "v3.1.0"}, {url: "./releases/v3.0.0/beacon-node-oapi.json", name: "v3.0.0"}, {url: "./releases/v2.5.0/beacon-node-oapi.json", name: "v2.5.0"}, {url: "./releases/v2.4.2/beacon-node-oapi.json", name: "v2.4.2"}, {url: "./releases/v2.4.1/beacon-node-oapi.json", name: "v2.4.1"}, {url: "./releases/v2.4.0/beacon-node-oapi.json", name: "v2.4.0"}, {url: "./releases/v2.3.0/beacon-node-oapi.json", name: "v2.3.0"}, {url: "./releases/v2.2.0/beacon-node-oapi.json", name: "v2.2.0"}, {url: "./beacon-node-oapi.yaml", name: "dev"} ], basePath: "/", dom_id: '#swagger-ui', displayRequestDuration: true, deepLinking: true, docExpansion: "none", queryConfigEnabled: "true", presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], plugins: [ SwaggerUIBundle.plugins.DownloadUrl ], layout: "StandaloneLayout" }); window.ui = ui; } ``` -------------------------------- ### Serve Beacon API Spec Locally (Python) Source: https://github.com/ethereum/beacon-apis/blob/master/README.md Use this command to serve the API specification locally using Python's http.server module. Access the rendered spec at http://localhost:8080. ```python python -m http.server 8080 ``` -------------------------------- ### Connect to Event Stream Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md This snippet shows how to establish a connection to the SSE endpoint to receive real-time beacon chain updates for specified topics. ```APIDOC ## GET /eth/v1/events ### Description Provides Server-Sent Events (SSE) for real-time beacon chain updates. ### Method GET ### Endpoint /eth/v1/events ### Parameters #### Query Parameters - **topics** (string) - Required - Comma-separated list of topics to subscribe to (e.g., `head,block,finalized_checkpoint`). ### Request Example ```bash curl --header "Accept: text/event-stream" \ "http://localhost:5052/eth/v1/events?topics=head,block,finalized_checkpoint" ``` ### Response #### Success Response (200) Events are streamed in the format: ``` event: {topic} data: {json_data} ``` **Available Topics:** - `head`: New block at chain tip. - `block`: Block passes validation. - `attestation`: Attestation received and aggregated. - `voluntary_exit`: Exit message received. - `finalized_checkpoint`: Epoch finalized by fork choice. - `chain_reorg`: Fork choice selects different head. - `blob_sidecar`: Blob sidecar received. - `payload_attestation`: Payload attestation received. #### Response Example (head event) ```json { "slot": "1000", "block": "0xcf8e0d4e...", "state": "0x9c2d...", "epoch_transition": false, "previous_duty_dependent_root": "0x...", "current_duty_dependent_root": "0x..." } ``` #### Response Example (finalized_checkpoint event) ```json { "block": "0xcf8e0d4e...", "state": "0x...", "epoch": "100" } ``` ``` -------------------------------- ### GET /eth/v1/beacon/light_client/optimistic_update Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Get the latest light client optimistic update. This endpoint retrieves the most recent optimistic update for the light client. ```APIDOC ## GET /eth/v1/beacon/light_client/optimistic_update ### Description Get the latest light client optimistic update. This endpoint retrieves the most recent optimistic update for the light client. ### Method GET ### Endpoint /eth/v1/beacon/light_client/optimistic_update ### Request Example (No explicit request body example provided) ### Response #### Success Response (200) - **version** (string) - - **data** (object) - #### Response Example ```json { "version": "gloas", "data": {...} } ``` ### Error Responses - `500`: Internal Server Error ``` -------------------------------- ### Query Beacon State by Identifier Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/README.md Use 'head', 'genesis', 'finalized', a slot number, or a state root to query the state. ```bash curl http://localhost:5052/eth/v1/beacon/states/head/root # Chain tip curl http://localhost:5052/eth/v1/beacon/states/finalized/root # Finalized curl http://localhost:5052/eth/v1/beacon/states/1000/root # By slot curl http://localhost:5052/eth/v1/beacon/states/0xabcd.../root # By root ``` -------------------------------- ### GET /eth/v1/beacon/light_client/finality_update Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Get the latest light client finality update. This endpoint retrieves the most recent finality update for the light client. ```APIDOC ## GET /eth/v1/beacon/light_client/finality_update ### Description Get the latest light client finality update. This endpoint retrieves the most recent finality update for the light client. ### Method GET ### Endpoint /eth/v1/beacon/light_client/finality_update ### Request Example (No explicit request body example provided) ### Response #### Success Response (200) - **version** (string) - - **data** (object) - - **attested_header** (object) - - **finalized_header** (object) - - **finality_branch** (array) - - **sync_aggregate** (object) - - **signature_slot** (string) - #### Response Example ```json { "version": "gloas", "data": { "attested_header": {...}, "finalized_header": {...}, "finality_branch": [...], "sync_aggregate": {...}, "signature_slot": "1" } } ``` ### Error Responses - `500`: Internal Server Error ``` -------------------------------- ### Prepare Beacon Proposer Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Just before the block production epoch, validators need to prepare as a beacon proposer. This request specifies the validator index and the fee recipient address. ```bash POST /eth/v1/validator/prepare_beacon_proposer Content-Type: application/json [ { "validator_index": "0", "fee_recipient": "0xAbcF8e0d4e9587369b2301D0790347320302cc09" } ] ``` -------------------------------- ### Get Node Version (v1) Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Retrieve the client implementation and version string of the Beacon Node. Useful for verifying the software version running. ```json { "data": { "version": "Lighthouse/v1.0.0 (Linux x86_64)" } } ``` -------------------------------- ### Generate RANDAO Reveal and Request Block Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Demonstrates how to generate the RANDAO reveal and make a request to the beacon node to produce a block for a specific slot. Ensure the correct Eth-Consensus-Version header is used. ```bash # Generate RANDAO reveal DOMAIN_RANDAO = compute_domain(BEACON_PROPOSER, current_fork) randao_reveal = Sign(slot, domain_randao, validator_private_key) curl -X GET "http://localhost:5052/eth/v3/validator/blocks/3200?randao_reveal=0x..." \ -H "Eth-Consensus-Version: gloas" ``` -------------------------------- ### Publish Signed Block to Network Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Shows how to publish a signed beacon block to the network using a POST request. The `broadcast_validation` query parameter can be adjusted based on desired validation level. ```bash curl -X POST http://localhost:5052/eth/v2/beacon/blocks \ -H "Content-Type: application/json" \ -H "Eth-Consensus-Version: gloas" \ -d '{ "message": {...block...}, "signature": "0x..." }' \ -G --data-urlencode 'broadcast_validation=consensus' ``` -------------------------------- ### Query Beacon Block by Identifier Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/README.md Use 'head', 'genesis', 'finalized', a slot number, or a block root to query blocks. ```bash curl http://localhost:5052/eth/v2/beacon/blocks/head/attestations # Chain tip curl http://localhost:5052/eth/v2/beacon/blocks/finalized/attestations # Finalized curl http://localhost:5052/eth/v2/beacon/blocks/1000/attestations # By slot curl http://localhost:5052/eth/v2/beacon/blocks/0xabcd.../attestations # By root ``` -------------------------------- ### Connect to Event Stream Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/configuration.md Use curl to connect to the SSE endpoint and subscribe to specific topics like head, block, and finalized_checkpoint. ```bash curl --header "Accept: text/event-stream" \ "http://localhost:5052/eth/v1/events?topics=head,block,finalized_checkpoint" ``` -------------------------------- ### Sync Committee Duties Response Example Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/validator-reference.md Example JSON response for the sync committee duties endpoint. Key fields include the validator's public key, index, and their position within the sync committee. ```json { "data": [ { "pubkey": "0x93247f2209abcacf57b75a51dafae777f9dd38bc7053d1af526f220a7489a6d3a2753e5f3e8b1cfe39b56f43611df74a", "validator_index": "0", "validator_sync_committee_index": "42" } ], "execution_optimistic": false } ``` -------------------------------- ### POST /eth/v1/validator/prepare_beacon_proposer Request Body Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Example request body for preparing the beacon proposer with fee recipient information. This involves specifying the validator index and the fee recipient address. ```json [ { "validator_index": "0", "fee_recipient": "0x" } ] ``` -------------------------------- ### Get Node Version (v2) Source: https://github.com/ethereum/beacon-apis/blob/master/_autodocs/endpoints.md Retrieve the client implementation, version string, and version number of the Beacon Node. Provides more detailed version information than v1. ```json { "data": { "version": "Lighthouse/v1.0.0 (Linux x86_64)", "implementation": "Lighthouse", "version_number": "1.0.0" } } ```