File size: 1,639 Bytes
44f0c63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * Basic Usage Example - Audit Proof Circuit
 * 
 * This example demonstrates how to use the Audit Proof circuit
 * with the AffixIO SDK in sandbox mode (no API key required for testing).
 * 
 * ⚠️ Note: Sandbox mode is for testing only. Production requires an API key.
 * 
 * Prerequisites:
 * - npm install @affixio/sdk
 * - npm install typescript @types/node ts-node
 * 
 * Run with: npx ts-node examples/basic-usage.ts
 */

import { AffixIO } from '@affixio/sdk';

async function main() {
  // Initialize SDK in sandbox mode (no API key needed for testing)
  const sdk = new AffixIO({
    sandbox: true
  });

  console.log('🔐 Generating audit proof in sandbox mode...\n');
  console.log('⚠️  Note: Sandbox mode is for testing only. Production requires an API key.\n');

  // Generate audit proof
  const result = await sdk.circuits.auditProof({
    decisionValue: 1, // Decision: approved
    pseudonymisedId: '0x1234567890abcdef1234567890abcdef',
    rulesHash: '0xabcdef1234567890abcdef1234567890',
    timestamp: new Date().toISOString()
  }, true); // Use sandbox mode

  console.log('✅ Audit Proof Generated:');
  console.log('   Decision:', result.decision ? 'Verified' : 'Failed');
  console.log('   Verified:', result.verified);
  console.log('   Proof ID:', result.proofId);
  console.log('   Proof:', result.proof.substring(0, 50) + '...');
  console.log('   Public Inputs:', result.publicInputs);
  console.log('\n✨ Audit proof generated successfully!');
  console.log('\n📝 For production use, get your API key at: https://dashboard.affix-io.com');
}

// Run the example
main().catch(console.error);