Creates a schema with validation and IPFS upload.
Creation configuration
Parameters for creating a new schema with automatic IPFS upload.
The name of the schema
The dialect of the schema (e.g., 'json' or 'sqlite')
The schema definition object or JSON string
Schema ID, IPFS URL, and transaction hash
Retrieves a complete schema by its ID with definition fetched and flattened.
The ID of the schema to retrieve
Optional parameters
OptionalsubgraphUrl?: stringCustom subgraph URL to use instead of default
Promise resolving to the complete schema object with all fields populated
const schema = await vana.schemas.get(1);
console.log(`Schema: ${schema.name} (${schema.dialect})`);
console.log(`Version: ${schema.version}`);
console.log(`Description: ${schema.description}`);
console.log('Schema:', schema.schema);
// Use directly with validator (schema has all required fields)
validator.validateDataAgainstSchema(data, schema);
Gets the total number of schemas registered on the network.
Optional parameters
OptionalsubgraphUrl?: stringCustom subgraph URL to use instead of default
Promise resolving to the total schema count
Lists all schemas with pagination.
Optional parameters for listing schemas
Optionallimit?: numberMaximum number of schemas to return
Optionaloffset?: numberNumber of schemas to skip
OptionalsubgraphUrl?: stringCustom subgraph URL to use instead of default
OptionalincludeDefinitions?: booleanWhether to fetch and include schema definitions (default: false for performance)
OptionalminBlock?: numberOptionalwaitForSync?: numberPromise resolving to an array of schemas
// Get all schemas (without definitions for performance)
const schemas = await vana.schemas.list();
// Get schemas with definitions
const schemas = await vana.schemas.list({ includeDefinitions: true });
// Get schemas with pagination
const schemas = await vana.schemas.list({ limit: 10, offset: 0 });
Retrieves schema definition content directly from a URL.
The definition URL (typically from schema.definitionUrl)
Promise resolving to the formatted definition content
Retrieves refinement instruction content from a URL.
The instruction URL (typically from refiner.refinementInstructionUrl)
Promise resolving to the formatted instruction content
Adds a schema using the legacy method (low-level API).
Schema parameters including pre-generated definition URL
Promise resolving to the add schema result
Manages data schemas for validation and structure definition on Vana.
Remarks
Handles schema lifecycle from creation through registration. Schemas define data structure and validation rules, ensuring consistency across the network. Stored unencrypted on IPFS for public reusability.
Architecture: Schemas use dual storage: definitions on IPFS (public), metadata on blockchain. Supports JSON Schema and SQLite dialects for flexible data modeling.
Method Selection:
create()- Validate, upload to IPFS, register on blockchainget()- Retrieve schema with definition by IDlist()- Paginated schema browsing with metadatacount()- Total schemas for paginationaddSchema()- Low-level registration with pre-uploaded URLStorage Requirements:
create()get(),list(),count(),addSchema()Example
See
For conceptual overview, visit https://docs.vana.org/docs/schemas