Vana SDK - v0.1.0
    Preparing search index...

    Manages data schemas and refiners on the Vana network.

    This controller handles the complete lifecycle of data schemas including creation, validation, IPFS upload, and blockchain registration. It provides methods for managing both schemas (data structure definitions) and refiners (data processing definitions).

    Schemas are public protocol entities that define data structures and validation rules. Unlike private user data, schemas are stored unencrypted on IPFS to enable public access and reusability across the network.

    // Create a new schema with automatic IPFS upload
    const result = await vana.schemas.create({
    name: "User Profile",
    type: "personal",
    definition: {
    type: "object",
    properties: {
    name: { type: "string" },
    age: { type: "number" }
    },
    required: ["name"]
    }
    });

    // Get an existing schema
    const schema = await vana.schemas.get(1);

    // List all schemas
    const count = await vana.schemas.count();
    Index

    Methods

    • Creates a new schema with automatic validation and IPFS upload.

      Parameters

      • params: CreateSchemaParams

        Schema creation parameters including name, type, and definition

      Returns Promise<CreateSchemaResult>

      Promise resolving to creation results with schema ID and transaction hash

      This is the primary method for creating schemas on the Vana network. It handles the complete workflow including schema validation, IPFS upload, and blockchain registration. The schema definition is stored unencrypted on IPFS to enable public access and reusability.

      The method automatically:

      • Validates the schema definition against the Vana metaschema
      • Uploads the definition to IPFS to generate a permanent URL
      • Registers the schema on the blockchain with the generated URL

      When the schema definition is invalid

      When IPFS upload or blockchain registration fails

      // Create a JSON schema for user profiles
      const result = await vana.schemas.create({
      name: "User Profile",
      type: "personal",
      definition: {
      type: "object",
      properties: {
      name: { type: "string" },
      age: { type: "number", minimum: 0 }
      },
      required: ["name"]
      }
      });

      console.log(`Schema created with ID: ${result.schemaId}`);
    • Retrieves a schema by its ID.

      Parameters

      • schemaId: number

        The ID of the schema to retrieve

      Returns Promise<Schema>

      Promise resolving to the schema object

      When the schema is not found or chain is unavailable

      const schema = await vana.schemas.get(1);
      console.log(`Schema: ${schema.name} (${schema.type})`);
    • Gets the total number of schemas registered on the network.

      Returns Promise<number>

      Promise resolving to the total schema count

      When the count cannot be retrieved

      const count = await vana.schemas.count();
      console.log(`Total schemas: ${count}`);
    • Lists all schemas with pagination.

      Parameters

      • options: { limit?: number; offset?: number } = {}

        Optional parameters for listing schemas

        • Optionallimit?: number

          Maximum number of schemas to return

        • Optionaloffset?: number

          Number of schemas to skip

      Returns Promise<Schema[]>

      Promise resolving to an array of schemas

      // Get all schemas
      const schemas = await vana.schemas.list();

      // Get schemas with pagination
      const schemas = await vana.schemas.list({ limit: 10, offset: 0 });