Livy Documentation

Quickstart

Learn how create, interact with and verify Livy Functions.

Quickstart

Deploy your first verifiable function and generate individual attestations in under 5 minutes. This guide walks you through creating a function in the Livy Console and interacting with it using our SDK.

Prerequisites

1. Create a Function

Access the Livy Console

  1. Log into your Livy Console
  2. Click "Add new service"

Write Your Rust Code

Note: This step only applies if you selected "Write Inline" or "Upload Files"

You'll need both main.rs and Cargo.toml files:

// This function will be verifiably executed
export default function handler(input) {
  const { name, numbers } = input;
  
  // Perform some calculation
  const sum = numbers ? numbers.reduce((a, b) => a + b, 0) : 0;
  const timestamp = new Date().toISOString();
  
  return {
    greeting: `Hello ${name}!`,
    sum: sum,
    timestamp: timestamp,
    verified: true
  };
}

Deploy

  1. Click "Deploy Function"
  2. Wait for deployment to complete (~30 seconds)
  3. Note your Service ID (e.g., f8577eaf-8a57-4c30-b5ed-9e74bd56f964)

Success

Your function is now live and ready to generate individual attestations!

2. Run Your Function

From Console

Test directly in the Console:

  1. Go to your function's Test tab
  2. Enter test input:
{
  "name": "Developer",
  "numbers": [1, 2, 3, 4, 5]
}
  1. Click "Run Function"
  2. View the result and generated attestation

With the Client SDK

npm install @livylabs/sdk

Create and run your client:

import { createClient } from '@livylabs/sdk';

const client = createClient({
  apiKey: 'sk-38cd1325c1606aac7ad25fa8ef386d863b4efd56cbd9044a577932a5b19b9b39'
});

async function main() {
  const result = await client.run({
    serviceId: 'f8577eaf-8a57-4c30-b5ed-9e74bd56f964',
    params: {
      name: "Developer",
      numbers: [1, 2, 3, 4, 5]
    },
    withAttestation: true
  });

  console.log(result);
}

main().catch(console.error);

3. Verify Your Attestation

Programmatic Verification

Using the SDK result from above:

async function main() {
  const result = await client.run({
    serviceId: 'f8577eaf-8a57-4c30-b5ed-9e74bd56f964',
    params: {
      name: "Developer", 
      numbers: [1, 2, 3, 4, 5]
    },
    withAttestation: true
  });

  console.log(result);

  // Verify the individual attestation
  const isValid = await result.verifyAttestation();

  console.log('isValid:', isValid);
  // Output: isValid: true
}

Console Verification

  1. Go to Functionsmy-first-function
  2. Click the Attestations tab
  3. Find your execution in the list
  4. Click "Verify Attestation"
  5. See the cryptographic proof validation

Manual Verification

You can also verify attestations independently:

import { createClient } from '@livylabs/sdk';

const client = createClient({
  apiKey: 'your-api-key'
});

// Verify any attestation by ID
const verification = await client.verifyAttestation('att_abc123xyz');

console.log('Verification result:', verification);
// {
//   valid: true,
//   attestationId: "att_abc123xyz",
//   functionHash: "0x1a2b3c...",
//   provenanceVerified: true,
//   signatureValid: true
// }

Congratulations! You've deployed your first verifiable function. Every execution is now individually attested and cryptographically verifiable.