@3mate/walrus-sponsor-sdk 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +142 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -444,6 +444,7 @@ COMMANDS
|
|
|
444
444
|
fund <id> --coin <id>
|
|
445
445
|
|
|
446
446
|
url <blob_id> Print aggregator URL
|
|
447
|
+
docs Print full documentation (for AI agents)
|
|
447
448
|
|
|
448
449
|
FLAGS
|
|
449
450
|
--pretty Pretty-print JSON output
|
|
@@ -456,6 +457,143 @@ EXAMPLES
|
|
|
456
457
|
krilly cost --size 1048576 --epochs 3
|
|
457
458
|
`);
|
|
458
459
|
}
|
|
460
|
+
function docs() {
|
|
461
|
+
console.log(`
|
|
462
|
+
# Krilly \u2014 Walrus Sponsor Service SDK & CLI
|
|
463
|
+
# Full documentation for AI agents and developers
|
|
464
|
+
# https://walrus-sponsor.krill.tube/docs
|
|
465
|
+
|
|
466
|
+
## What is this?
|
|
467
|
+
Krilly is the SDK and CLI for the Walrus Sponsor Service \u2014 sponsored decentralized
|
|
468
|
+
blob storage on the Walrus network (built on Sui blockchain). You upload files,
|
|
469
|
+
the platform pays for storage, and the blob is stored permanently on Walrus.
|
|
470
|
+
|
|
471
|
+
## Key Concepts
|
|
472
|
+
- WAL: Native token of Walrus, used to pay for storage. 1 WAL = 1,000,000,000 FROST.
|
|
473
|
+
- Epoch: Storage time unit. 1 epoch \u2248 14 days on mainnet. Max 53 epochs.
|
|
474
|
+
- SponsoredBlob: On-chain Sui object wrapping a Walrus blob with creator/sponsor tracking.
|
|
475
|
+
- creator_address: Any valid Sui address (0x + 64 hex). The owner of the blob.
|
|
476
|
+
The creator does NOT need a wallet or tokens \u2014 the sponsor pays.
|
|
477
|
+
- blob_id: Walrus content ID (Base64 string). Used for reading/downloading.
|
|
478
|
+
- object_id / sponsored_blob_id: On-chain object ID (0x...). Used for management ops.
|
|
479
|
+
- Workspace: Billing boundary with its own balance and API keys.
|
|
480
|
+
|
|
481
|
+
## Setup
|
|
482
|
+
1. Get an API key from https://walrus-sponsor.krill.tube (sign in \u2192 create workspace \u2192 API Keys)
|
|
483
|
+
2. Run: krilly config set-key <your_api_key>
|
|
484
|
+
|
|
485
|
+
## CLI Commands
|
|
486
|
+
|
|
487
|
+
### Upload a file
|
|
488
|
+
krilly upload <file_path> --creator <sui_address> [--epochs <n>] [--deletable]
|
|
489
|
+
Example: krilly upload ./photo.jpg --creator 0x123...abc --epochs 5
|
|
490
|
+
Returns: JSON with blob_id, sponsored_blob_id, tx_digest, wal_cost, status
|
|
491
|
+
|
|
492
|
+
### List blobs
|
|
493
|
+
krilly blobs [--status active|expired|deleted] [--limit <n>] [--offset <n>] [--pretty]
|
|
494
|
+
Example: krilly blobs --status active --limit 10 --pretty
|
|
495
|
+
|
|
496
|
+
### Get blob details
|
|
497
|
+
krilly blob <object_id>
|
|
498
|
+
Example: krilly blob 0xabc...
|
|
499
|
+
|
|
500
|
+
### Estimate cost
|
|
501
|
+
krilly cost --size <bytes> --epochs <n> [--pretty]
|
|
502
|
+
Example: krilly cost --size 1048576 --epochs 3 --pretty
|
|
503
|
+
|
|
504
|
+
### Get download URL
|
|
505
|
+
krilly url <blob_id>
|
|
506
|
+
Returns a public aggregator URL. No auth needed to read blobs.
|
|
507
|
+
|
|
508
|
+
### Check service
|
|
509
|
+
krilly health
|
|
510
|
+
krilly epoch
|
|
511
|
+
|
|
512
|
+
### Delete blob (advanced \u2014 requires on-chain object IDs)
|
|
513
|
+
krilly delete <sponsored_blob_id> --system-object <walrus_system_object_id>
|
|
514
|
+
|
|
515
|
+
### Extend storage (advanced \u2014 requires on-chain object IDs)
|
|
516
|
+
krilly extend <sponsored_blob_id> --epochs <n> --system-object <id> --payment-coin <id>
|
|
517
|
+
|
|
518
|
+
### Fund blob (advanced \u2014 requires on-chain coin ID)
|
|
519
|
+
krilly fund <sponsored_blob_id> --coin <funds_coin_id>
|
|
520
|
+
|
|
521
|
+
## SDK (programmatic usage in Node.js / TypeScript)
|
|
522
|
+
|
|
523
|
+
import { WalrusSponsor } from "krilly";
|
|
524
|
+
|
|
525
|
+
const client = new WalrusSponsor({
|
|
526
|
+
apiKey: "sbk_live_...",
|
|
527
|
+
baseUrl: "https://walrus-sponsor.krill.tube", // optional, this is the default
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// Upload
|
|
531
|
+
const result = await client.upload("./file.txt", {
|
|
532
|
+
creatorAddress: "0x...",
|
|
533
|
+
epochs: 3,
|
|
534
|
+
deletable: true,
|
|
535
|
+
});
|
|
536
|
+
console.log(result.blobId, result.sponsoredBlobId);
|
|
537
|
+
|
|
538
|
+
// Upload from buffer
|
|
539
|
+
const result2 = await client.upload(
|
|
540
|
+
{ data: Buffer.from("hello"), filename: "hello.txt", contentType: "text/plain" },
|
|
541
|
+
{ creatorAddress: "0x...", epochs: 1 }
|
|
542
|
+
);
|
|
543
|
+
|
|
544
|
+
// List blobs
|
|
545
|
+
const { blobs, total } = await client.blobs({ status: "active", limit: 50 });
|
|
546
|
+
|
|
547
|
+
// Get blob details
|
|
548
|
+
const blob = await client.blob("0xabc...");
|
|
549
|
+
|
|
550
|
+
// Estimate cost
|
|
551
|
+
const cost = await client.storageCost(1048576, 3);
|
|
552
|
+
console.log(cost.total_cost, cost.storage_cost, cost.write_cost);
|
|
553
|
+
|
|
554
|
+
// Get download URL (no network call)
|
|
555
|
+
const url = client.getBlobUrl(result.blobId);
|
|
556
|
+
|
|
557
|
+
// Health check
|
|
558
|
+
const health = await client.health();
|
|
559
|
+
|
|
560
|
+
// Epoch info
|
|
561
|
+
const epoch = await client.epoch();
|
|
562
|
+
|
|
563
|
+
## REST API (for non-JS languages)
|
|
564
|
+
Base URL: https://walrus-sponsor.krill.tube
|
|
565
|
+
Auth: Bearer token in Authorization header
|
|
566
|
+
|
|
567
|
+
POST /v1/upload \u2014 Upload file (multipart form: file, creator_address, epochs, deletable)
|
|
568
|
+
GET /v1/blobs \u2014 List blobs (?status=active&limit=20)
|
|
569
|
+
GET /v1/blobs/:id \u2014 Get blob by object_id
|
|
570
|
+
GET /v1/storage-cost \u2014 Estimate cost (?size=1048576&epochs=3)
|
|
571
|
+
POST /v1/delete \u2014 Delete blob (requires sponsored_blob_id, walrus_system_object_id)
|
|
572
|
+
POST /v1/extend \u2014 Extend storage (requires sponsored_blob_id, epochs, walrus_system_object_id, payment_coin_id)
|
|
573
|
+
POST /v1/fund \u2014 Add WAL to blob (requires sponsored_blob_id, funds_coin_id)
|
|
574
|
+
GET /health \u2014 Health check (no auth)
|
|
575
|
+
GET /epoch \u2014 Current epoch info (no auth)
|
|
576
|
+
|
|
577
|
+
Rate limit: 60 requests/minute per API key. Returns X-RateLimit-* headers.
|
|
578
|
+
|
|
579
|
+
## Error Handling
|
|
580
|
+
- 400: Missing or invalid parameters
|
|
581
|
+
- 401: Invalid or missing API key
|
|
582
|
+
- 402: Insufficient workspace balance
|
|
583
|
+
- 429: Rate limited (retry after X-RateLimit-Reset)
|
|
584
|
+
- 500: Server error
|
|
585
|
+
- 502: Publisher or storage node unavailable
|
|
586
|
+
|
|
587
|
+
## Tips for AI Agents
|
|
588
|
+
- Install with: npm install -g krilly-cli (for CLI) or npm install krilly (for SDK)
|
|
589
|
+
- Ask the user for their API key, then run: krilly config set-key <key>
|
|
590
|
+
- For uploads: you need a file path and a creator_address (any valid Sui 0x address)
|
|
591
|
+
- Reading blobs is free and public \u2014 use krilly url <blob_id> to get the download link
|
|
592
|
+
- Check costs before uploading: krilly cost --size <bytes> --epochs <n>
|
|
593
|
+
- Add --pretty flag for readable JSON output
|
|
594
|
+
- Full docs: https://walrus-sponsor.krill.tube/docs
|
|
595
|
+
`);
|
|
596
|
+
}
|
|
459
597
|
async function main() {
|
|
460
598
|
const args = process.argv.slice(2);
|
|
461
599
|
if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
|
|
@@ -470,6 +608,10 @@ async function main() {
|
|
|
470
608
|
case "config":
|
|
471
609
|
handleConfig(rest, pretty);
|
|
472
610
|
return;
|
|
611
|
+
case "docs": {
|
|
612
|
+
docs();
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
473
615
|
case "health": {
|
|
474
616
|
const client = getClient();
|
|
475
617
|
out(await client.health(), pretty);
|
package/package.json
CHANGED