Examples
Examples (SDK vNext)
Installation
npm install @treza/sdkQuick Start
import { TrezaClient } from '@treza/sdk';
const client = new TrezaClient({
baseUrl: process.env.TREZA_BASE_URL ?? 'https://app.trezalabs.com',
timeout: 30_000,
});
const WALLET = process.env.WALLET_ADDRESS!; // e.g. '0x4B0897b0513fdc7C541B6d9D7E929C4e5364D2dB'
async function main() {
// 1) Discover providers
const providers = await client.getProviders();
const provider = providers[0];
console.log('Using provider:', provider.name, provider.id);
// 2) Create an enclave
const enclave = await client.createEnclave({
name: 'My Trading Bot',
description: 'Secure environment for trading algorithms',
region: provider.regions[0] ?? 'us-east-1',
walletAddress: WALLET,
providerId: provider.id,
providerConfig: {
dockerImage: 'trading-bot:latest',
cpuCount: 2,
memoryMiB: 512,
},
});
console.log('Enclave created:', enclave.id, 'status:', enclave.status);
// 3) Get logs (application-only)
const appLogs = await client.getEnclaveLogs(enclave.id, 'application', 50);
console.log('Application log entries:', (appLogs.logs.application ?? []).length);
// 4) Pause → Resume lifecycle
const paused = await client.pauseEnclave(enclave.id, WALLET);
console.log('Paused →', paused.enclave.status);
const resumed = await client.resumeEnclave(enclave.id, WALLET);
console.log('Resumed →', resumed.enclave.status);
}
main().catch((e) => {
console.error(e);
process.exit(1);
});Provider Management
Enclave Management (Create / Update / Delete)
Enclave Lifecycle (Pause / Resume / Terminate)
Logs (Application, Errors, and Providers)
Docker Hub Helpers
Tasks (Scheduling inside Enclaves)
API Keys (Least-Privilege Access)
GitHub OAuth (Optional)
Error Handling
Types (What You Can Import)
Example Runner (Monorepo-friendly)
Troubleshooting
See Also
Last updated