DeFindex Docs
  • DeFindex Protocol
    • Welcome
    • What is DeFindex?
  • Getting Started
    • How DeFindex Works
    • Creating a DeFindex Vault
    • Mainnet Deployment
  • Whitepaper
    • Whitepaper
      • Introduction
        • Core Concepts
      • The DeFindex Approach
        • Design Decisions
      • Smart Contracts
        • DeFindex Vault
        • DeFindex Strategy
        • DeFindex Zapper
      • Strategy Examples
      • State of the Art
        • Yearn Finance
      • Appendix
        • Why Not Swap in Deposit
  • WALLET DEVELOPER
    • Flutter SDK
    • Typescript SDK
    • Vault APY
  • STRATEGIES
    • What is a strategy?
    • What is Blend Capital?
    • Strategies APY
  • Users
    • About Us
    • General/FAQ
      • Additional Resources
  • Security
    • Security Audit
Powered by GitBook
On this page
Edit on GitHub
  1. WALLET DEVELOPER

Typescript SDK

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

  1. Install the SDK

npm install defindex-sdk
# or
yarn add defindex-sdk
  1. Import and Initialize

import { Vault, SorobanNetwork } from 'defindex-sdk';

const vault = new Vault({
    network: SorobanNetwork.TESTNET,
    contractId: 'YOUR_VAULT_CONTRACT_ID'
});
  1. 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
);
PreviousFlutter SDKNextVault APY

Last updated 6 months ago

Page cover image