The TypeScript SDK provides a simple way to interact with DeFindex vaults in your web applications. You can easily integrate vault functionality with just a few lines of code. The SDK handles all the complexities of Soroban contract interactions while providing a type-safe interface.
Getting Started
Install the SDK
npm install defindex-sdk
# or
yarn add defindex-sdk
Import and Initialize
import { Vault, SorobanNetwork } from 'defindex-sdk';
const vault = new Vault({
network: SorobanNetwork.TESTNET,
contractId: 'YOUR_VAULT_CONTRACT_ID'
});
Use Vault Functions
// Check balance
const balance = await vault.balance(accountAddress, sorobanContext);
// Make a deposit
const txHash = await vault.deposit(
accountAddress,
100,
true,
sorobanContext,
secretKey // Optional secret key for signing, if you are using a connected wallet it's not needed
);
// Withdraw funds
const withdrawTxHash = await vault.withdraw(
accountAddress,
50,
true,
sorobanContext,
secretKey // Optional secret key for signing, if you are using a connected wallet it's not needed
);