Wallet SDK
The Wallet SDK provides a complete interface for MPC wallet management, transaction building, and key custody. It wraps the tenzro-wallet crate functionality and is available in both the TypeScript and Rust SDKs. Wallets are auto-provisioned as 2-of-3 MPC threshold wallets with no seed phrases required.
Create a Wallet
import { TenzroClient } from "@tenzro/sdk";
const client = new TenzroClient("https://rpc.tenzro.network");
// Create a new MPC wallet (auto-provisions 2-of-3 shares)
const wallet = await client.wallet.create({
keyType: "ed25519", // or "secp256k1" for EVM compatibility
});
console.log("Address:", wallet.address);
console.log("Key type:", wallet.keyType);
console.log("Threshold:", wallet.threshold); // 2
console.log("Total shares:", wallet.totalShares); // 3# Create via RPC
curl -X POST https://rpc.tenzro.network \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tenzro_createWallet",
"params": [{"key_type": "ed25519"}],
"id": 1
}'Transaction Building
The SDK provides a type-safe transaction builder with automatic gas estimation per transaction type:
// Build and send a transaction
const tx = await client.wallet.send({
to: "0xRecipient...",
value: "5000000000000000000", // 5 TNZO
});
console.log("Tx hash:", tx.hash);
console.log("Nonce:", tx.nonce);
console.log("Gas used:", tx.gasUsed);
// The SDK automatically:
// 1. Queries nonce via eth_getTransactionCount
// 2. Queries chain ID via eth_chainId
// 3. Estimates gas for the transaction type
// 4. Signs with the MPC wallet (2-of-3 threshold)
// 5. Verifies the signature post-signing
// 6. Submits via eth_sendRawTransactionBalance Queries
// Query TNZO balance
const balance = await client.wallet.getBalance("0xAddress...");
console.log("Balance:", balance.tnzo, "TNZO");
// Multi-asset balance (TNZO, USDC, USDT, ETH, SOL, BTC)
const balances = await client.wallet.getAllBalances("0xAddress...");
for (const [asset, amount] of Object.entries(balances)) {
console.log(asset + ":", amount);
}Session Keys
// Create a time-limited session key
const session = await client.wallet.createSessionKey({
permissions: ["transfer", "inference"],
maxTransactionValue: "1000000000000000000", // 1 TNZO per tx
expiresIn: 3600, // 1 hour
allowedContracts: ["0xModelRegistry..."],
});
// Use the session key for signing (no master key access needed)
const tx = await client.wallet.sendWithSessionKey(session.key, {
to: "0xProvider...",
value: "100000000000000000", // 0.1 TNZO
});
// Revoke a session key early
await client.wallet.revokeSessionKey(session.publicKey);Spending Policies
// Set spending limits (via TDIP delegation scope)
await client.wallet.setSpendingPolicy({
maxTransactionValue: "10000000000000000000", // 10 TNZO
maxDailySpend: "100000000000000000000", // 100 TNZO
allowedOperations: ["transfer", "inference", "stake"],
allowedContracts: ["0xModelRegistry...", "0xStaking..."],
});
// Query current policy
const policy = await client.wallet.getSpendingPolicy();
console.log("Daily limit:", policy.maxDailySpend);
console.log("Daily spent:", policy.dailySpent);Keystore Import/Export
// Export encrypted keystore (Argon2id + AES-256-GCM)
const keystore = await client.wallet.exportKeystore("my-password");
// keystore is a JSON file with:
// { version, kdf_params, cipher, ciphertext, nonce, tag }
// Import from encrypted keystore
const imported = await client.wallet.importKeystore(
keystoreJson,
"my-password"
);
console.log("Imported address:", imported.address);Transaction History
// Query transaction history with lifecycle tracking
const history = await client.wallet.getTransactionHistory({
address: "0xAddress...",
limit: 50,
offset: 0,
});
// Transaction states:
// Created → Pending → Confirmed → Finalized
// → Failed
// → Dropped
for (const tx of history) {
console.log(tx.hash, tx.status, tx.timestamp);
}Nonce Management
The SDK provides automatic per-address sequential nonce management with replay protection and on-chain sync support. Nonces are tracked locally and synchronized with the chain state to prevent gaps and replays.
CLI Reference
# Create wallet
tenzro-cli wallet create
# Import wallet from keystore
tenzro-cli wallet import --keystore /path/to/keystore.json
# Check balance (calls eth_getBalance)
tenzro-cli wallet balance
# Send TNZO (queries nonce + chain ID, builds tx, sends)
tenzro-cli wallet send --to 0xRecipient... --amount 10.0
# List all wallets
tenzro-cli wallet list