Skip to main content
Research Preview — This API is under development.

Distance

Calculate the distance between two geometries in meters.
POST /compute/v0/distance

Request Body

chainId
number
required
Target chain ID. All UIDs must exist on this chain.
from
Input
required
First geometry. Can be a UID, GeoJSON, or offchain attestation reference.
to
Input
required
Second geometry. Can be a UID, GeoJSON, or offchain attestation reference.
schema
string
required
EAS schema UID to issue the attestation against.
recipient
string
Ethereum address to receive the attestation. Defaults to zero address if not provided.

Example Request

curl -X POST https://api.astral.global/compute/v0/distance \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": 84532,
    "from": "0xabc123...",
    "to": {
      "type": "Point",
      "coordinates": [2.2945, 48.8584]
    },
    "schema": "0xschema...",
    "recipient": "0xdef456..."
  }'

Response

result
number
required
Distance in meters (e.g., 523.45)
units
string
required
Always “meters”
operation
string
required
Always “distance”
timestamp
number
required
Unix timestamp of computation
inputRefs
string[]
required
Array of input references (UIDs or geometry hashes)
attestation
object
required
The signed attestation object
delegatedAttestation
object
required
Signature for delegated onchain submission

Example Response

{
  "result": 523.45,
  "units": "meters",
  "operation": "distance",
  "timestamp": 1706400000,
  "inputRefs": [
    "0xabc123...",
    "0x7d3e8f..."
  ],
  "attestation": {
    "schema": "0x...",
    "attester": "0x...",
    "recipient": "0xdef456...",
    "data": "0x...",
    "signature": "0x..."
  },
  "delegatedAttestation": {
    "signature": "0x...",
    "attester": "0x...",
    "deadline": 1706403600
  }
}

Notes

  • Distance is calculated using PostGIS ST_Distance with geodetic coordinates
  • Result is in meters with centimeter precision (rounded to 0.01m)
  • For raw GeoJSON inputs, a keccak256 hash is used in inputRefs

SDK Method

See astral.compute.distance()