Scripts for Aleph Backend API with smart contract integration.
- Auto-generated TypeScript client from Swagger
- Manager wallet authentication via Privy
- Smart contract integration for on-chain data
- Settlement automation with automatic batch ID fetching
pnpm installCopy and configure your environment variables:
cp env.example .envEdit .env with your values:
# API Configuration
ALEPH_API_URL=http://localhost:3000
ALEPH_TIMEOUT=10000
# Manager Authentication
PRIVATE_KEY_MANAGER=0x...
PRIVY_MANAGER_APP_ID=clxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
SIWE_DOMAIN_MANAGER=your-frontend-domain.com
# Blockchain Configuration
RPC_URL=https://rpc.sepolia.ethpandaops.io
# Settlement Configuration (format: <chainId>_<vaultAddress>)
VAULT_ID=11155111_0x1234567890123456789012345678901234567890
CLASS_ID=1Generate the TypeScript client from your backend's Swagger spec:
pnpm run generateThis fetches ${ALEPH_API_URL}/swagger.json and generates the client to src/generated/backend-client/.
Run the authentication example:
pnpm run exampleExpected output:
🚀 Aleph API Scripts - Manager Authentication Example
📋 Step 1: Checking API health...
✅ Health check passed
📋 Step 2: Authenticating as manager...
✅ Authentication successful!
📋 Step 3: Calling protected API endpoint...
✅ Manager identified: { ... }
✅ Example completed successfully!
Execute settlement with NAV (batch ID fetched automatically from blockchain):
pnpm run settle-deposit 1000000.5What happens:
- Parses
VAULT_IDto extract chain ID and vault address - Fetches current batch ID from vault contract on-chain
- Authenticates with manager wallet
- Submits settlement to backend API
Output:
{
"success": true,
"message": "Deposit batch settled successfully",
"batchId": 2
}pnpm run generate # Generate API client from Swagger
pnpm run example # Test authentication
pnpm run settle-deposit # Run settlement (requires <nav> argument)
pnpm run build # Build TypeScript
pnpm run dev # Watch mode| Variable | Required | Description |
|---|---|---|
ALEPH_API_URL |
Yes | Backend API URL |
PRIVATE_KEY_MANAGER |
Yes | Manager wallet private key |
PRIVY_MANAGER_APP_ID |
Yes | Privy app ID for managers |
SIWE_DOMAIN_MANAGER |
Yes | Frontend domain for SIWE |
RPC_URL |
Yes* | Blockchain RPC endpoint (*for settlement) |
VAULT_ID |
Yes* | Format: <chainId>_<vaultAddress> (*for settlement) |
CLASS_ID |
Yes* | Vault class ID (*for settlement) |
- Verify private key is correct
- Check Privy App ID matches your configuration
- Ensure SIWE domain matches your frontend
- Backend server must be running
- Swagger must be accessible at
${ALEPH_API_URL}/swagger.json - Check
.envfile hasALEPH_API_URLset
- Verify
VAULT_IDformat:<chainId>_<vaultAddress> - Ensure RPC_URL is accessible
- Check vault address is correct
- Confirm manager wallet has permissions
ISC