Getting Started
Get up and running with zkVault in minutes. Install the SDK, authenticate, and create your first vault.
Installation
npm
npm install @vault-protocol/sdk
yarn
yarn add @vault-protocol/sdk
pnpm
pnpm add @vault-protocol/sdk
Environment Setup
Create a .env file in your project root:
# API Configuration NEXT_PUBLIC_API_URL=https://api.vaultprotocol.ai NEXT_PUBLIC_API_KEY=your_api_key_here # Blockchain RPC (opBNB Primary) NEXT_PUBLIC_OPBNB_RPC_URL=https://opbnb-mainnet-rpc.bnbchain.org NEXT_PUBLIC_OPBNB_TESTNET_RPC_URL=https://opbnb-testnet-rpc.bnbchain.org # Lit Protocol NEXT_PUBLIC_LIT_NETWORK=datil-test # WalletConnect NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id_here
Note: Get your API key from the zkVault Dashboard
Authentication
Initialize the SDK
import { VaultProtocolSDK } from '@vault-protocol/sdk';
import { ethers } from 'ethers';
// Connect wallet
const provider = new ethers.providers.Web3Provider(window.ethereum);
await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner();
// Initialize SDK
const sdk = new VaultProtocolSDK({
provider,
signer,
network: 'opbnb', // or 'opbnb-testnet'
apiUrl: process.env.NEXT_PUBLIC_API_URL,
litNetwork: 'datil-test',
});
// Authenticate
const authToken = await sdk.authenticate();
console.log('Authenticated:', authToken);Create Your First Vault
Basic Vault Creation
// Create vault configuration
const vaultConfig = {
name: "My First Vault",
releaseType: "DEADMAN", // or "SCHEDULED", "HYBRID"
checkInPeriod: 90 * 24 * 60 * 60, // 90 days in seconds
recipients: [
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb", // Beneficiary address
],
encrypted: true,
};
// Create the vault
const vault = await sdk.vaultManager.createVault(vaultConfig);
console.log('Vault created:', vault.id);
// Upload encrypted content (e.g., seed phrase)
const content = {
data: "word1 word2 word3 ... word24", // Your seed phrase
encrypted: true,
storageLocation: 'arweave',
contentType: 'text/plain',
};
const contentCID = await sdk.vaultManager.uploadContent(
vault.id,
content
);
console.log('Content uploaded:', contentCID);Configure Deadman Switch
// Configure deadman switch
await sdk.timeManager.configureDeadmanSwitch(
vault.id,
90 * 24 * 60 * 60, // Check-in period: 90 days
7 * 24 * 60 * 60 // Grace period: 7 days
);
// Perform check-in to reset the timer
await sdk.timeManager.checkIn(vault.id);
console.log('Check-in successful!');Quick Reference
Release Types
SCHEDULED- Release at specific timeDEADMAN- Release if no check-inHYBRID- Both scheduled + deadman
Storage Options
arweave- Permanent storage (recommended)ipfs- Decentralized storageceramic- Metadata storage