Ethereum Kit

Overview

Understanding the Ethereum Kit architecture

The Shelby Protocol Ethereum Kit SDK is built to bridge the gap between Ethereum and the Shelby Protocol, enabling Ethereum developers to use their existing wallets for decentralized blob storage.

Architecture

The SDK provides two entry points for different environments:

┌─────────────────────────────────────────────────────────────────────────┐
│                       Your Ethereum Application                          │
├─────────────────────────────────────────────────────────────────────────┤
│                     @shelby-protocol/ethereum-kit                        │
│                                                                          │
│  ┌─────────────────────────────┐    ┌─────────────────────────────────┐ │
│  │         /node               │    │           /react                │ │
│  │  ┌───────────────────────┐  │    │  ┌───────────────────────────┐  │ │
│  │  │   Shelby Client       │  │    │  │   useStorageAccount       │  │ │
│  │  │   (extends SDK)       │  │    │  │   (React Hook)            │  │ │
│  │  └───────────────────────┘  │    │  └───────────────────────────┘  │ │
│  │  ┌───────────────────────┐  │    │                                 │ │
│  │  │ ShelbyStorageAccount  │  │    │  Uses viem WalletClient for:   │ │
│  │  │ (Wallet → Account)    │  │    │  - Address derivation          │ │
│  │  └───────────────────────┘  │    │  - Transaction signing         │ │
│  └─────────────────────────────┘    └─────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────┤
│                         @shelby-protocol/sdk                             │
│  ┌───────────────────────────┐    ┌───────────────────────────────────┐ │
│  │   Coordination Layer      │    │   RPC Operations                  │ │
│  │   (Aptos Chain)           │    │   (Blob Storage)                  │ │
│  └───────────────────────────┘    └───────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘

Entry Points

Node.js (/node)

For server-side applications with direct access to Ethereum wallets:

  • Shelby Client: Extends the core SDK with Ethereum-specific initialization
  • ShelbyStorageAccount: Converts an ethers.js Wallet into a Shelby signer
  • Use cases: Backend services, scripts, CLIs, automated uploads
import { Shelby, Network } from "@shelby-protocol/ethereum-kit/node";

React (/react)

For browser applications with wallet connections:

  • useStorageAccount Hook: Derives storage account from connected wallet
  • Wallet Integration: Works with wagmi's useWalletClient() and viem types
  • Use cases: React dApps, Next.js applications, browser-based uploads
import { useStorageAccount } from "@shelby-protocol/ethereum-kit/react";
import { useWalletClient } from "wagmi";

Cross-Chain Flow

Both entry points use the same underlying cross-chain mechanism:

Node.js Flow

┌──────────────┐     ┌──────────────────────┐     ┌─────────────────┐
│   ethers.js  │────▶│ ShelbyStorageAccount │────▶│  Shelby Client  │
│   Wallet     │     │   (Signs with SIWE)  │     │  (Uploads blob) │
└──────────────┘     └──────────────────────┘     └─────────────────┘
  1. ethers.js Wallet → Provided directly (from private key, env, etc.)
  2. ShelbyStorageAccount → Signs transactions with SIWE envelope
  3. Shelby Client → Submits to the coordination layer

React Flow

┌──────────────┐     ┌──────────────────────┐     ┌─────────────────┐
│   Wallet     │────▶│  useStorageAccount   │────▶│  Shelby Client  │
│  (MetaMask)  │     │ (Prompts for sign)   │     │  (Uploads blob) │
└──────────────┘     └──────────────────────┘     └─────────────────┘
  1. Wallet → User connects via wagmi (RainbowKit, Web3Modal, etc.)
  2. useStorageAccount → Derives address, prompts user to sign
  3. Shelby Client → Submits to the coordination layer

SIWE (Sign-In With Ethereum)

Both entry points use the SIWE envelope format for transaction signing:

  1. Transaction Data → Serialized Aptos transaction
  2. SIWE Message → Human-readable message wrapping the transaction
  3. Ethereum Signature → ECDSA signature from Ethereum wallet
  4. Authenticator → Wrapped signature compatible with Aptos

This enables Ethereum identities to control accounts on the Aptos-based Shelby network.

Common Module

Both entry points share common functionality:

ExportDescription
NetworkNetwork configuration (currently SHELBYNET)

Choosing an Entry Point

RequirementUse Node.js (/node)Use React (/react)
Direct wallet access
Wallet popup for signing
Server-side execution
Browser environment
Automated/batch operations
User-initiated transactions