Skip to content

Implement saveShards Method - Save Key Shards to Lighthouse Nodes #28

Open
@AkashJana18

Description

@AkashJana18

Overview

Implement the saveShards method in Python SDK to store key shards securely on Lighthouse distributed nodes. This method backs up shards on the network and allows access delegation by sharing shards to multiple addresses.

The API contract must match exactly with the JS SDK implementation.


Function Signature

async def saveShards(
    address: str,
    cid: str,
    auth_token: str,
    keyShards: List[Dict[str, str]],
    shareTo: Optional[List[str]] = None
) -> Dict[str, Any]:
    pass

Expected Response Format

{
  "isSuccess": true,
  "error": null
}

Reference (JS SDK)

  • File: /src/methods/saveShards/index.ts
  • Method: saveShards()

Key Requirements

  • Perform HTTP request to Lighthouse Node’s save API endpoint.
  • Include auth_token for authentication (received via getAuthMessage + signature).
  • Prepare request body following same structure as JS SDK payload.
  • Handle optional shareTo parameter for sharing shards during save operation.
  • Fully mirror the Lighthouse API behavior.
  • Handle and parse errors from Lighthouse API into SDK-consistent response.

Suggested Python Libraries

  • Use httpx or requests for asynchronous HTTP calls.
  • Use pydantic or standard dataclasses for request/response schema validation.
  • Use standard Python logging for debugging API requests.

Deliverables

  • Fully functional saveShards() method.

  • Unit tests for:

    • Valid shard save with and without shareTo.
    • Error cases from Lighthouse API.
  • Maintain full consistency in payload and response with JS SDK behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions