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

Length

Calculate the length of a line in meters.
POST /compute/v0/length

Request body

chainId
number
required
Target chain ID (e.g., 84532 for Base Sepolia).
geometry
Input
required
The line geometry to measure. See Input types for accepted formats.
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/length \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{
    "chainId": 84532,
    "geometry": "0xline...",
    "recipient": "0xdef456..."
  }'

Response

Returns a NumericComputeResponse.
result
number
required
Length in meters (e.g., 2345.67).
units
string
required
Always "meters".
operation
string
required
Always "length".
timestamp
number
required
Unix timestamp of computation.
inputRefs
string[]
required
Array of input references.
attestation
AttestationData
required
Signed EAS attestation. See AttestationData.
delegatedAttestation
DelegatedAttestationData
required
Signature for delegated onchain submission. See DelegatedAttestationData.

Example response

{
  "result": 2345.67,
  "units": "meters",
  "operation": "length",
  "timestamp": 1706400000,
  "inputRefs": [
    "0xline..."
  ],
  "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_Length with geodetic calculation
  • Result is in meters with centimeter precision
  • The onchain attested value is scaled to centimeters (integer) for EVM compatibility
  • Valid for LineString and MultiLineString geometries

SDK Method

See astral.compute.length()