warlot-sdk
v1.0.0
Published
TypeScript SDK for the Walrus decentralized backend platform
Downloads
4
Maintainers
Readme
@warlot/sdk
A TypeScript SDK for interacting with the Walrus decentralized backend platform. This SDK is designed to simplify the process of building applications that leverage Walrus's decentralized storage and compute capabilities.
This SDK is configured to use the testnet and sends all blobs, objects, and data to the address 0x1cb9d68b284e49c41e576b3c3933269ab39cd0eb0268616ac1ea4a5ba57a15de.
Features
- Create and manage projects
- Define tables with custom schemas
- Query data using SQL-like syntax
- Upload and manage files in storage buckets
- Built-in TypeScript support
- Promise-based API
Installation
npm install @warlot/sdk
# or
yarn add @warlot/sdkQuick Start
import {
createProject,
getProjects,
getProjectById,
createTable,
insertRow,
queryTable
} from '@warlot/sdk';
// Create a project
const project = await createProject('My App', '0x1cb9d68b284e49c41e576b3c3933269ab39cd0eb0268616ac1ea4a5ba57a15de');
// Create a table
const table = await createTable(project.id, 'users', [
{ name: 'id', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'email', type: 'string' }
], '0x1cb9d68b284e49c41e576b3c3933269ab39cd0eb0268616ac1ea4a5ba57a15de');
// Insert data
await insertRow(project.id, 'users', {
id: '1',
name: 'John Doe',
email: '[email protected]'
}, '0x1cb9d68b284e49c41e576b3c3933269ab39cd0eb0268616ac1ea4a5ba57a15de');
// Query data
const users = await queryTable(project.id, 'SELECT * FROM users', '0x1cb9d68b284e49c41e576b3c3933269ab39cd0eb0268616ac1ea4a5ba57a15de');API Reference
Projects
createProject(name: string, sendTo: string): Promise<Project>
Creates a new project.
getProjects(sendTo: string): Promise<Project[]>
Lists all projects.
getProjectById(projectId: string, sendTo: string): Promise<Project>
Gets a specific project by ID.
Tables
createTable(projectId: string, tableName: string, columns: Column[], sendTo: string): Promise<Table>
Creates a new table in a project.
getTables(projectId: string, sendTo: string): Promise<Table[]>
Lists all tables in a project.
insertRow(projectId: string, tableName: string, row: Row, sendTo: string): Promise<void>
Inserts a new row into a table.
queryTable(projectId: string, sqlQuery: string, sendTo: string): Promise<Row[]>
Executes a SQL query on a table.
Storage
createBucket(projectId: string, bucketName: string, sendTo: string): Promise<Bucket>
Creates a new storage bucket.
getBuckets(projectId: string): Promise<Bucket[]>
Lists all buckets in a project.
uploadToBucket(projectId: string, bucketName: string, file: File | Blob, sendTo: string): Promise<string>
Uploads a file to a bucket. Returns the file URL.
downloadFromBucket(projectId: string, bucketName: string, fileName: string, sendTo: string): Promise<Blob>
Downloads a file from a bucket.
deleteFile(projectId: string, bucketName: string, fileName: string, sendTo: string): Promise<void>
Deletes a file from a bucket.
Development
- Clone the repository
git clone https://github.com/yourusername/walrus-sdk.git
cd walrus-sdk- Install dependencies
npm install- Build the SDK
npm run build- Run tests
npm test- Run example
npm run exampleTesting
The SDK includes a comprehensive test suite:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watchPublishing
To publish this SDK to npm under the name @warlot/sdk, you will need to:
- Update the
package.jsonfile with the correct version number. - Run
npm run buildto build the SDK. - Run
npm publish --access publicto publish the SDK to npm.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
