|
| 1 | +# Ethereum File Upload Example |
| 2 | + |
| 3 | +A Next.js example application demonstrating how Ethereum developers can build a file upload dApp on [Shelby Protocol](https://shelby.xyz). This app allows users to connect their Ethereum wallet and upload files to decentralized storage. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Connect Ethereum wallets via [RainbowKit](https://www.rainbowkit.com/) |
| 8 | +- Upload files to Shelby's decentralized storage |
| 9 | +- Automatic storage account derivation from Ethereum address |
| 10 | +- Beautiful, modern UI with drag-and-drop file uploads |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- [Node.js](https://nodejs.org/) v18 or higher |
| 15 | +- [pnpm](https://pnpm.io/) package manager |
| 16 | +- An Ethereum wallet (e.g., MetaMask) |
| 17 | +- A Shelby API key |
| 18 | + |
| 19 | +## Getting Started |
| 20 | + |
| 21 | +### 1. Clone the Repository |
| 22 | + |
| 23 | +```bash |
| 24 | +git clone https://github.com/shelby-protocol/shelby-examples.git |
| 25 | +cd shelby-examples/apps/ethereum/file-upload |
| 26 | +``` |
| 27 | + |
| 28 | +### 2. Install Dependencies |
| 29 | + |
| 30 | +From the monorepo root: |
| 31 | + |
| 32 | +```bash |
| 33 | +pnpm install |
| 34 | +``` |
| 35 | + |
| 36 | +Or from this directory: |
| 37 | + |
| 38 | +```bash |
| 39 | +pnpm install |
| 40 | +``` |
| 41 | + |
| 42 | +### 3. Set Up Environment Variables |
| 43 | + |
| 44 | +Copy the example environment file: |
| 45 | + |
| 46 | +```bash |
| 47 | +cp .env.example .env |
| 48 | +``` |
| 49 | + |
| 50 | +### 4. Get Your Shelby API Key |
| 51 | + |
| 52 | +1. Visit the [Shelby API Keys documentation](https://docs.shelby.xyz/sdks/typescript/acquire-api-keys) |
| 53 | +2. Follow the instructions to acquire your API key |
| 54 | +3. Add your API key to the `.env` file: |
| 55 | + |
| 56 | +```env |
| 57 | +NEXT_PUBLIC_SHELBY_API_KEY=your-api-key-here |
| 58 | +``` |
| 59 | + |
| 60 | +### 5. Run the Development Server |
| 61 | + |
| 62 | +```bash |
| 63 | +pnpm dev |
| 64 | +``` |
| 65 | + |
| 66 | +Open [http://localhost:3000](http://localhost:3000) in your browser. |
| 67 | + |
| 68 | +## How It Works |
| 69 | + |
| 70 | +This example uses the following Shelby packages: |
| 71 | + |
| 72 | +- [`@shelby-protocol/sdk`](https://docs.shelby.xyz/sdks/typescript) - Core TypeScript SDK for interacting with Shelby Protocol |
| 73 | +- [`@shelby-protocol/ethereum-kit`](https://docs.shelby.xyz/sdks/typescript) - Ethereum-specific utilities for wallet integration |
| 74 | +- [`@shelby-protocol/react`](https://docs.shelby.xyz/sdks/typescript) - React hooks for blob uploads |
| 75 | + |
| 76 | +### Key Components |
| 77 | + |
| 78 | +- **FileUploader** - Main component handling file selection and upload |
| 79 | +- **Header** - Wallet connection using RainbowKit |
| 80 | +- **providers.tsx** - Wagmi and RainbowKit configuration |
| 81 | + |
| 82 | +### Storage Account |
| 83 | + |
| 84 | +When you connect your Ethereum wallet, a Shelby storage account is automatically derived from your Ethereum address. This allows you to upload and manage files using your existing wallet. |
| 85 | + |
| 86 | +## Learn More |
| 87 | + |
| 88 | +- [Shelby Documentation](https://docs.shelby.xyz) |
| 89 | +- [TypeScript SDK Reference](https://docs.shelby.xyz/sdks/typescript) |
| 90 | +- [Shelby Explorer](https://explorer.shelby.xyz) - View your uploaded files |
| 91 | + |
| 92 | +## License |
| 93 | + |
| 94 | +MIT |
0 commit comments