> ## Documentation Index
> Fetch the complete documentation index at: https://astral-6ef288be-docs-policy-evaluation-framing.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Schemas

> EAS schema definitions for Astral attestations

<Warning>
  **Research Preview** — Additional schema UIDs will be published as they are deployed.
</Warning>

# EAS Schemas

Astral Location Services uses the Ethereum Attestation Service (EAS) for all attestations. This page documents the schema definitions.

## Location Attestation Schema

Used for storing spatial data (points, polygons, routes).

```
bytes geometry, string geometryType, string srs, bytes properties
```

| Field          | Type   | Description                                     |
| -------------- | ------ | ----------------------------------------------- |
| `geometry`     | bytes  | Encoded GeoJSON geometry                        |
| `geometryType` | string | "Point", "Polygon", "LineString", etc.          |
| `srs`          | string | Spatial reference system (default: "EPSG:4326") |
| `properties`   | bytes  | JSON-encoded metadata                           |

***

## Policy Attestation Schemas

Output schemas for geospatial computations.

### BooleanPolicyAttestation

For predicate operations (`contains`, `within`, `intersects`).

```
bool result, bytes32[] inputRefs, uint64 timestamp, string operation
```

| Field       | Type       | Description                                                                                                                      |
| ----------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `result`    | bool       | The boolean computation result                                                                                                   |
| `inputRefs` | bytes32\[] | References to inputs (UIDs or hashes)                                                                                            |
| `timestamp` | uint64     | Unix timestamp of computation                                                                                                    |
| `operation` | string     | Operation with parameters (e.g., "within:50000", "contains") — the `within` radius is encoded in centimeters; see the note below |

### NumericPolicyAttestation

For measurement operations (`distance`, `length`, `area`).

```
uint256 result, string units, bytes32[] inputRefs, uint64 timestamp, string operation
```

| Field       | Type       | Description                                          |
| ----------- | ---------- | ---------------------------------------------------- |
| `result`    | uint256    | Scaled integer result (centimeters or cm²)           |
| `units`     | string     | Base unit ("meters" or "square\_meters")             |
| `inputRefs` | bytes32\[] | References to inputs                                 |
| `timestamp` | uint64     | Unix timestamp of computation                        |
| `operation` | string     | Operation with parameters (e.g., "distance", "area") |

### GeometryPolicyAttestation (Future)

For transformation operations (`buffer`, `centroid`, `union`).

```
bytes geometry, string geometryType, bytes32[] inputRefs, uint64 timestamp, string operation
```

<Note>
  **Operation strings include parameters** — For example, the `within` operation returns `"within:50000"` (radius in centimeters), not just `"within"`. Resolver contracts should use prefix matching when validating operations.
</Note>

***

## Default Schema UIDs

Astral provides pre-registered schemas without resolver contracts for general use. Use these when you don't need custom validation logic.

### Base Sepolia (84532)

| Schema                   | UID                                                                  | Use For                            |
| ------------------------ | -------------------------------------------------------------------- | ---------------------------------- |
| BooleanPolicyAttestation | `0x4958625091a773dcfb37a1c33099a378f32a975a7fb61f33d53c4be7589898f5` | `contains`, `within`, `intersects` |
| NumericPolicyAttestation | *Register your own*                                                  | `distance`, `length`, `area`       |
| Location                 | *Register your own*                                                  | Location attestations              |

<Note>
  The BooleanPolicyAttestation schema UID above is the default used by the staging API. For production use or custom resolver logic, register your own schema.
</Note>

<Info>
  **Custom schemas**: If you need a resolver contract for custom validation (like the Location-Gated NFT), register your own schema with the same field types. The schema UID will be different, but the data encoding is identical.
</Info>

***

## Input References

The `inputRefs` array contains a `bytes32` for each input:

| Input Type           | Reference                        |
| -------------------- | -------------------------------- |
| Onchain attestation  | The UID                          |
| Offchain attestation | The UID                          |
| Raw GeoJSON          | `keccak256(abi.encode(geojson))` |

This enables verification that specific inputs were used:

```solidity theme={null}
(bool result, bytes32[] memory inputRefs, , ) = abi.decode(...);

// Verify expected landmark was checked
require(inputRefs[1] == EXPECTED_LANDMARK_UID, "Wrong location");
```

***

## Result Scaling

Numeric results are stored as scaled integers:

| Measurement | Storage            | Conversion              |
| ----------- | ------------------ | ----------------------- |
| Distance    | centimeters        | `meters = result / 100` |
| Length      | centimeters        | `meters = result / 100` |
| Area        | square centimeters | `m² = result / 10000`   |

```solidity theme={null}
// In your resolver
(uint256 resultCm, , , , ) = abi.decode(...);
uint256 meters = resultCm / 100;
```

***

## Decoding in Solidity

### Boolean Policy

```solidity theme={null}
function decodeBooleanPolicy(bytes memory data) public pure returns (
    bool result,
    bytes32[] memory inputRefs,
    uint64 timestamp,
    string memory operation
) {
    return abi.decode(data, (bool, bytes32[], uint64, string));
}
```

### Numeric Policy

```solidity theme={null}
function decodeNumericPolicy(bytes memory data) public pure returns (
    uint256 result,
    string memory units,
    bytes32[] memory inputRefs,
    uint64 timestamp,
    string memory operation
) {
    return abi.decode(data, (uint256, string, bytes32[], uint64, string));
}
```

***

## Schema Registry

Schemas are registered in the EAS SchemaRegistry. When deploying your resolver:

```typescript theme={null}
import { SchemaRegistry } from '@ethereum-attestation-service/eas-sdk';

const registry = new SchemaRegistry(REGISTRY_ADDRESS);

// Register schema with your resolver
// IMPORTANT: Use revocable: true - Astral signs with revocable=true
const tx = await registry.connect(signer).register({
  schema: "bool result,bytes32[] inputRefs,uint64 timestamp,string operation",
  resolverAddress: yourResolver.address,
  revocable: true
});

const receipt = await tx.wait();
const schemaUID = receipt.logs[0].args.uid;
```

<Card title="Next: Security" icon="shield" href="/resources/security">
  Security considerations
</Card>
