Create a new TLSNotaryService instance
Connected Demos instance with wallet
Request attestation token and create a pre-configured TLSNotary instance
This is the recommended way to perform attestations. It handles:
The returned TLSNotary instance is ready to call attest() immediately.
Request options including target URL
OptionalonStatus: StatusCallbackOptional status callback for progress updates
Object with TLSNotary instance, tokenId, and proxyUrl
const service = new TLSNotaryService(demos);
// Get a ready-to-use TLSNotary instance
const { tlsn, tokenId, proxyUrl } = await service.createTLSNotary({
targetUrl: 'https://api.github.com/users/octocat'
});
// Perform attestation - the proxy is already configured!
const result = await tlsn.attest({
url: 'https://api.github.com/users/octocat',
});
// Store proof on-chain
await service.storeProof(tokenId, JSON.stringify(result.presentation), { storage: 'onchain' });
Request attestation token and create a pre-configured TLSNotary instance WITH user confirmation before broadcasting the transaction.
This is the recommended way to perform attestations in user-facing applications. It handles:
Request options including target URL
Options containing the confirmation callback
OptionalonStatus: StatusCallbackOptional status callback for progress updates
Object with TLSNotary instance, tokenId, and proxyUrl
const service = new TLSNotaryService(demos);
// Get a ready-to-use TLSNotary instance with user confirmation
const { tlsn, tokenId, proxyUrl } = await service.createTLSNotaryWithConfirmation(
{ targetUrl: 'https://api.github.com/users/octocat' },
{
onConfirm: async (details) => {
// Show confirmation dialog to user in your UI
return await showConfirmDialog({
title: 'Confirm Attestation',
message: `Burn ${details.amount} DEM for attestation?`,
txHash: details.txHash,
});
}
},
(status) => console.log(status)
);
// Perform attestation - the proxy is already configured!
const result = await tlsn.attest({
url: 'https://api.github.com/users/octocat',
});
Get attestation token information by token ID
The attestation token ID
Token information or null if not found
Get attestation token information by transaction hash
The transaction hash of the TLSN_REQUEST transaction
Token information or null if not found
Request an attestation token for a target URL
This submits a TLSN_REQUEST native transaction that burns 1 DEM and returns a token ID with a proxy URL for performing the attestation.
Request options including target URL
Attestation token response with proxyUrl and tokenId
Request an attestation token with user confirmation before broadcasting
This method shows the transaction details to the user via the onConfirm callback and only broadcasts if the user confirms. This is the recommended way to request attestation tokens in user-facing applications.
Request options including target URL
Options containing the confirmation callback
Attestation token response with proxyUrl and tokenId
const { proxyUrl, tokenId } = await service.requestAttestationWithConfirmation(
{ targetUrl: 'https://api.github.com/users/octocat' },
{
onConfirm: async (details) => {
// Show confirmation dialog to user
return await showConfirmDialog({
title: 'Confirm Attestation Request',
message: `This will burn ${details.amount} DEM to request attestation for ${details.targetUrl}`,
txHash: details.txHash,
});
}
}
);
Store a TLSNotary proof on-chain or IPFS
This submits a TLSN_STORE native transaction that burns:
The attestation token ID
The proof data (JSON string or serialized presentation)
Storage options (on-chain or IPFS)
Storage response with transaction hash and fee
Store a TLSNotary proof on-chain or IPFS with user confirmation
This method shows the transaction details to the user via the onConfirm callback and only broadcasts if the user confirms. This is the recommended way to store proofs in user-facing applications.
The attestation token ID
The proof data (JSON string or serialized presentation)
Storage options (on-chain or IPFS)
Options containing the confirmation callback
Storage response with transaction hash and fee
const { txHash, storageFee } = await service.storeProofWithConfirmation(
tokenId,
JSON.stringify(presentation),
{ storage: 'onchain' },
{
onConfirm: async (details) => {
// Show confirmation dialog to user
return await showConfirmDialog({
title: 'Confirm Proof Storage',
message: `This will burn ${details.amount} DEM to store the proof on-chain`,
txHash: details.txHash,
});
}
}
);
TLSNotary Service for managing attestation tokens and proof storage