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

Within

Check if a geometry is within a specified radius of a target geometry.
POST /compute/v0/within

Request body

chainId
number
required
Target chain ID (e.g., 84532 for Base Sepolia).
geometry
Input
required
The geometry to check (typically a point). See Input types for accepted formats.
target
Input
required
The target geometry to measure distance from.
radius
number
required
Maximum distance in meters.
schema
string
EAS schema UID. The server uses a default schema if not provided.
recipient
string
Ethereum address to receive the attestation. Defaults to the zero address.

Example request

curl -X POST https://api.astral.global/compute/v0/within \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{
    "chainId": 84532,
    "geometry": "0xpoint...",
    "target": "0xlandmark...",
    "radius": 500,
    "recipient": "0xdef456..."
  }'

Response

Returns a BooleanComputeResponse.
result
boolean
required
true if the geometry is within the radius of the target.
operation
string
required
Encodes the radius in centimeters: "within:RADIUS_CM" (e.g., "within:50000" for a 500m radius).
timestamp
number
required
Unix timestamp of computation.
inputRefs
string[]
required
Array containing [geometryRef, targetRef].
attestation
AttestationData
required
Signed EAS attestation. See AttestationData.
delegatedAttestation
DelegatedAttestationData
required
Signature for delegated onchain submission. See DelegatedAttestationData.

Example response

{
  "result": true,
  "operation": "within:50000",
  "timestamp": 1706400000,
  "inputRefs": [
    "0xpoint...",
    "0xlandmark..."
  ],
  "attestation": {
    "schema": "0x...",
    "attester": "0x590fdb53ed3f0B52694876d42367192a5336700F",
    "recipient": "0xdef456...",
    "data": "0x...",
    "revocable": true,
    "refUID": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "signature": "0x..."
  },
  "delegatedAttestation": {
    "signature": "0x...",
    "attester": "0x590fdb53ed3f0B52694876d42367192a5336700F",
    "deadline": 1706403600,
    "nonce": 0
  }
}

Notes

  • Uses PostGIS ST_DWithin function
  • Radius is always in meters in the request (no unit conversion needed)
  • The operation field encodes the radius in centimeters: within:50000 means 500 meters. Resolver contracts should use prefix matching, not exact string comparison
  • Returns true if the distance between geometries is less than or equal to the radius

SDK Method

See astral.compute.within()