Deploy confidential applications with Phala Cloud’s managed TEE infrastructure.
You can derive a deterministic key using the Dstack SDK inside Docker. Under the hood, the TappdClient derives the key from the application root key.
Copy
Ask AI
import { TappdClient } from '@phala/dstack-sdk';const keyResult = await client.deriveKey('<unique-id>'); // Same unique-id will get same keyconsole.log(keyResult.key); // X.509 private key in PEM formatconsole.log(keyResult.certificate_chain); // Certificate chainconst keyBytes = keyResult.asUint8Array(); // Get key as Uint8Array
DStack SDK provides a helper function to derive a viem compatible wallet.
Copy
Ask AI
import { toViemAccount } from '@phala/dstack-sdk/viem';const keyResult = await client.deriveKey('<unique-id>'); // Same unique-id will get same keyconst account = toViemAccount(keyResult);// Use the account with viem operations
If you want to derive a Solana wallet, you can use the following code that derive a Solana wallet based on Solana Web3.js.
Copy
Ask AI
import { toKeypair } from '@phala/dstack-sdk/solana';const keyResult = await client.deriveKey('<unique-id>'); // Same unique-id will get same keyconst keypair = toKeypair(keyResult);