@tenzro/platform
v1.0.0
Published
Official TypeScript SDK for Tenzro Platform - multi-tenant infrastructure for building enterprise applications on the Canton Network
Maintainers
Readme
Tenzro Platform TypeScript SDK
Official TypeScript SDK for Tenzro Platform - multi-tenant infrastructure for building enterprise applications on the Canton Network.
Installation
npm install @tenzro/platformQuick Start
import { TenzroPlatform } from '@tenzro/platform';
const platform = new TenzroPlatform({
apiKey: process.env.TENZRO_API_KEY!,
tenantId: process.env.TENZRO_TENANT_ID!,
});
// AI inference with TEE attestation
const result = await platform.ai.infer({
modelId: 'llama-3.1-70b',
prompt: 'Analyze this transaction...',
maxTokens: 1024,
});
// Canton Ledger operations
const party = await platform.ledger.allocateParty({
displayName: 'Alice',
namespace: 'myapp',
});
// Cross-chain bridge via CCIP
const quote = await platform.bridge.getQuote({
sourceChain: 'base',
destinationChain: 'canton',
asset: 'USDC',
amount: '1000000000',
});
// MPC wallet with governance
const settings = await platform.wallet.getSettings();Configuration
const platform = new TenzroPlatform({
apiKey: string; // Required - your API key
tenantId: string; // Required - your tenant ID
baseUrl?: string; // Optional - defaults to https://api.platform.tenzro.com
timeout?: number; // Optional - request timeout in ms
});Services
AI Service
TEE-secured inference with GPU acceleration.
// List models
const models = await platform.ai.listModels();
// Run inference
const result = await platform.ai.infer({
modelId: 'llama-3.1-70b',
prompt: 'Your prompt...',
maxTokens: 1024,
temperature: 0.7,
});
console.log(result.content);
console.log(result.teeAttestation);
// Generate embeddings
const embeddings = await platform.ai.embed({
modelId: 'text-embedding-3-small',
input: ['document 1', 'document 2'],
});
// Chat completion
const chat = await platform.ai.chat({
modelId: 'llama-3.1-70b',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' },
],
});Ledger Service
Canton Network Ledger API with parties, contracts, and domains.
// Allocate party
const party = await platform.ledger.allocateParty({
displayName: 'Bob',
namespace: 'myapp',
hint: 'bob',
});
// Get balance
const balance = await platform.ledger.getBalance(party.identifier);
// Transfer assets
await platform.ledger.transfer({
fromParty: 'party::myapp::alice',
toParty: 'party::myapp::bob',
asset: 'USDC',
amount: '100000000',
});
// Create contract
const contract = await platform.ledger.createContract({
templateId: 'Asset.Token',
payload: { owner: party.identifier, amount: '1000' },
signatories: [party.identifier],
});
// Exercise choice
await platform.ledger.exerciseChoice({
contractId: contract.contractId,
choice: 'Transfer',
argument: { newOwner: 'party::myapp::bob' },
actingParties: [party.identifier],
});
// List domains
const domains = await platform.ledger.listDomains();Bridge Service
Cross-chain bridging via Chainlink CCIP.
// Get routes
const routes = await platform.bridge.getRoutes('base', 'canton');
// Get quote
const quote = await platform.bridge.getQuote({
sourceChain: 'base',
destinationChain: 'canton',
asset: 'USDC',
amount: '1000000000',
});
// Initiate bridge
const operation = await platform.bridge.initiate({
quoteId: quote.quoteId,
sender: '0x...',
recipient: 'party::myapp::alice',
});
// Track operation
const status = await platform.bridge.getOperation(operation.id);
// Cancel or retry
await platform.bridge.cancel(operation.id);
await platform.bridge.retry(operation.id);Wallet Service
MPC wallet governance with policies and approvals.
// Get/update settings
const settings = await platform.wallet.getSettings();
await platform.wallet.updateSettings({
dailyLimit: '10000000000',
requireApprovalAbove: '1000000000',
mfaRequired: true,
});
// Create spending policy
const policy = await platform.wallet.createPolicy({
name: 'Large Transfer Policy',
conditions: { minAmount: '1000000000' },
actions: { requireApprovals: 2 },
});
// Manage approvals
const approvals = await platform.wallet.listApprovals({ status: 'pending' });
await platform.wallet.approve(approvalId);
await platform.wallet.reject(approvalId);
// Whitelist management
await platform.wallet.addToWhitelist({
address: '0x...',
label: 'Treasury',
chain: 'ethereum',
});
const whitelist = await platform.wallet.listWhitelist();Anchor Service
State root anchoring with Merkle proofs.
// Submit state root
const anchor = await platform.anchor.submit({
stateRoot: '0x1234...5678',
namespace: 'myapp',
});
// Verify proof
const result = await platform.anchor.verify({
stateRoot: '0x1234...5678',
leaf: '0xabcd...ef01',
proof: ['0x...', '0x...'],
index: 0,
});
// Create batch
const batch = await platform.anchor.createBatch({
stateRoots: ['0x...', '0x...'],
namespace: 'myapp',
});Token Service
Asset tokenization with collections and minting.
// Create collection
const collection = await platform.token.createCollection({
name: 'Real Estate Fund',
symbol: 'REF',
tokenType: 'non_fungible',
maxSupply: '1000',
});
// Mint tokens
await platform.token.mint({
collectionId: collection.id,
recipient: '0x...',
tokenId: '1',
metadata: {
name: 'Property #1',
attributes: [{ traitType: 'Location', value: 'NYC' }],
},
});
// Transfer
await platform.token.transfer({
collectionId: collection.id,
tokenId: '1',
from: '0x...',
to: '0x...',
});Custody Service
TEE-secured MPC signing.
// Generate key
const key = await platform.custody.generateKeyPair({
algorithm: 'secp256k1',
label: 'Signing Key',
});
// Sign message
const signature = await platform.custody.sign({
keyId: key.keyId,
message: '0x...',
});
// Get attestation
const attestation = await platform.custody.getAttestation();API Keys Service
Manage API keys with per-service rate limits.
// Create key
const key = await platform.apiKeys.create({
name: 'Production Key',
scopes: ['ai:read', 'ledger:write'],
rateLimits: {
ai: { requestsPerMinute: 100 },
ledger: { requestsPerMinute: 1000 },
},
});
// List keys
const keys = await platform.apiKeys.list();
// Revoke key
await platform.apiKeys.revoke(keyId);Events Service
Real-time event streaming.
// Subscribe to events
const subscription = platform.events.subscribe('wallet', {
eventTypes: ['transaction.completed'],
onEvent: (event) => console.log(event),
});
// List events
const events = await platform.events.list('wallet', { limit: 100 });
// Clean up
subscription.close();Submodule Imports
import { AIClient } from '@tenzro/platform/ai';
import { LedgerClient } from '@tenzro/platform/ledger';
import { BridgeClient } from '@tenzro/platform/bridge';
import { WalletClient } from '@tenzro/platform/wallet';
import { AnchorClient } from '@tenzro/platform/anchor';
import { TokenClient } from '@tenzro/platform/token';
import { CustodyClient } from '@tenzro/platform/custody';
import { ApiKeysClient } from '@tenzro/platform/apikeys';
import { EventsClient } from '@tenzro/platform/events';Error Handling
import { TenzroApiError } from '@tenzro/platform';
try {
await platform.ai.infer({ ... });
} catch (error) {
if (error instanceof TenzroApiError) {
console.log(error.code); // 'RATE_LIMIT_EXCEEDED'
console.log(error.message);
console.log(error.status); // HTTP status
}
}Links
License
Apache 2.0 - Tenzro, Inc.
