TLSNotary API Reference
TLSNotaryService Class
TheTLSNotaryService class manages attestation tokens and proof storage. It provides methods for both direct execution and wallet-confirmation flows.
Methods
requestAttestation()
Requests an attestation token for a target URL. Burns 1 DEM and returns a proxy URL.requestAttestationWithConfirmation()
Same asrequestAttestation() but allows user confirmation before broadcasting. Recommended for wallet extension apps.
createTLSNotary()
Convenience method that handles the full setup: request token → get proxy → create TLSNotary instance → initialize WASM.createTLSNotaryWithConfirmation()
Same ascreateTLSNotary() but with user confirmation. Recommended for wallet extension apps.
storeProof()
Stores an attestation proof on-chain or IPFS.storeProofWithConfirmation()
Same asstoreProof() but with user confirmation. Recommended for wallet extension apps.
calculateStorageFee()
Calculate the fee for storing a proof.Response Types
AttestationTokenResponse
StoreProofResponse
TransactionDetails (for confirmation callbacks)
Native Transaction Types
TLSNotary uses two native transaction types:tlsn_request
Requests a TLSNotary attestation. Creates an access token for the proxy.tlsn_store
Stores the proof on-chain after notarization completes.Cost Structure
| Operation | Base Cost | Variable Cost | Notes |
|---|---|---|---|
tlsn_request | 1 DEM | - | Initial request fee |
tlsn_store | 1 DEM | +1 DEM/KB | Storage fee based on proof size |
| Gas | Standard | - | Network transaction gas |
- Small proof (1KB): 1 + 1 + 1 = 3 DEM + gas
- Medium proof (5KB): 1 + 1 + 5 = 7 DEM + gas
- Large proof (20KB): 1 + 1 + 20 = 22 DEM + gas
Error Codes
| Code | Description | Resolution |
|---|---|---|
TLSN_INVALID_URL | URL is not accessible or malformed | Verify URL format and accessibility |
TLSN_TIMEOUT | Notarization timed out | Retry or check target server |
TLSN_INSUFFICIENT_BALANCE | Not enough DEM for fees | Top up DEM balance |
TLSN_PROOF_TOO_LARGE | Proof exceeds maximum size | Reduce response size or use redactions |
TLSN_TOKEN_EXPIRED | Access token expired | Request will auto-retry |
TLSN_PROXY_UNAVAILABLE | No proxy available for domain | Wait and retry |
TLSNotary Class
TheTLSNotary class performs the actual WASM-based attestation. Use it after getting a proxy URL from TLSNotaryService.
attest() Signature
commit ranges and onStatus callback are passed as separate positional arguments, not as fields of the request object.
The request (AttestRequest) fields are:
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The target HTTPS URL to attest |
method | "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | No | HTTP method (default: “GET”) |
headers | Record<string, string> | No | Custom headers to include |
body | string | object | No | Request body for POST/PUT/PATCH requests |
maxSentData | number | No | Max sent data in bytes (default: 16384) |
maxRecvData | number | No | Max receive data in bytes (default: 16384) |
attest() Response
verify()
Verify an attestation proof:Wallet Extension Integration
For production dApps, users connect via wallet extensions which handle key management. The SDK supports a 3-step flow for wallet extensions:The 3-Step Wallet Flow
- Generate Transaction: Create the unsigned transaction
- Sign & Confirm: Send to wallet extension for user approval and signing
- Broadcast: Send the signed transaction to the network
WithConfirmation methods implement this pattern:
Custom Headers
POST Requests
Commit Ranges (Selective Disclosure)
Control which parts of the request/response to include in the proof:attestQuick() method accepts an AttestOptions object where commit and onStatus are fields: