Skip to main content

What is a Schema?

A schema is a template that defines what data an attestation contains. Every attestation references a schema, ensuring data consistency and enabling verification.

Why Schemas Matter

Data Consistency

Schemas enforce structure. An attestation using a KYC schema will always have the same fields, making it predictable for verifiers.

Interoperability

Different applications can issue attestations against the same schema. A “KYC verified” attestation from Provider A is structurally identical to one from Provider B.

Discoverability

Schemas are registered on-chain with unique identifiers. Applications can query for all attestations of a specific type.

Schema Components

Field Types

Schemas support these primitive types:

Encoding Formats

The SDK’s SorobanSchemaEncoder supports multiple encoding formats. Your choice of format affects how data is stored and indexed.
These encoding formats determine how your schema and attestation data are stored on-chain and indexed by our explorer. Choose the format that best fits your use case.

Typed Schema (Default)

Native typed schema with validation rules. Best for most use cases.
Features:
  • Type validation at encode time
  • Optional field validation (min, max, pattern, enum)
  • Auto-conversion for timestamps and addresses

JSON Schema

Standard JSON Schema format for interoperability with external tools.
Use cases:
  • Integration with JSON Schema validators
  • Generating forms from schemas
  • API documentation and OpenAPI specs

XDR Format

Stellar’s native binary format for efficient storage and selective disclosure.
Benefits:
  • Compact storage — Binary format reduces on-chain storage costs
  • Selective disclosure — Reveal only specific fields without exposing entire attestation
  • Native Soroban compatibility — Direct integration with contract data structures
XDR provides selective disclosure, not encryption. Data is structured so you can reveal individual fields while keeping others private. For true privacy, combine with off-chain encrypted storage.

Format Comparison

All three formats are fully supported by the AttestProtocol indexer and explorer. Your attestation data will be queryable regardless of encoding choice.

Schema UID

Every schema has a unique identifier derived from:
This means:
  • Same definition by different authorities = different UIDs
  • Same authority, different definition = different UIDs
  • Identical inputs always produce the same UID

Resolvers

A resolver is an optional smart contract that validates attestations before they’re created. Use cases:
  • Payment gates: Require fee payment before attestation
  • Eligibility checks: Verify the subject meets criteria
  • Rate limiting: Prevent spam attestations
  • Custom logic: Any business rules

Common Schema Patterns

Identity Verification

Credential

Membership

Reputation

Schema Lifecycle

  1. Create: Authority registers schema on-chain
  2. Discover: Others find schema by UID or query
  3. Use: Attesters create attestations referencing schema
  4. Verify: Verifiers decode attestation data using schema definition

Best Practices

Keep schemas minimal

Only include fields you need. Smaller schemas = lower costs.

Use appropriate types

u64 for timestamps, bool for flags, string for text.

Plan for revocation

Set revocable: true for credentials that may need invalidation.

Version your schemas

Include version in name: KYC_v2 for breaking changes.

Next Steps

Create a Schema

Step-by-step guide for Stellar

SDK Reference

Complete API documentation