Skip to main content

Build DeFi Applications withDeFi Smart Accounts

DSA Connect is the official JavaScript SDK for creating and managing DeFi Smart Accounts. Execute complex multi-protocol operations in a single transaction across Ethereum and EVM-compatible chains.

Quick start

Get up and running with DSA Connect in minutes

1

Install the SDK

Install DSA Connect using your preferred package manager:
npm install dsa-connect
DSA Connect requires Web3.js as a peer dependency. Make sure you have web3 v1.5.0 or higher installed.
2

Initialize the SDK

Create a DSA instance with your Web3 provider:
import Web3 from 'web3';
import DSA from 'dsa-connect';

// Browser environment
const web3 = new Web3(window.ethereum);
const dsa = new DSA(web3, 1); // 1 = Ethereum mainnet

// Node.js environment
const dsa = new DSA({
  web3: web3,
  mode: "node",
  privateKey: YOUR_PRIVATE_KEY
}, 1);
The second parameter is the chain ID. Supported chains: Ethereum (1), Polygon (137), Arbitrum (42161), Optimism (10), and more.
3

Create or connect a Smart Account

Build a new DSA or connect to an existing one:
// Create a new Smart Account
const txHash = await dsa.build();

// Or fetch existing accounts
const accounts = await dsa.getAccounts(address);

// Set the active account
await dsa.setInstance(accounts[0].id);
4

Execute your first transaction

Create a spell to interact with DeFi protocols:
// Create a spell to deposit ETH into Aave
const spells = dsa.Spell();

spells.add({
  connector: "aave-v2",
  method: "deposit",
  args: [
    "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH
    "1000000000000000000", // 1 ETH in wei
    0,
    0
  ]
});

// Execute the spell
const txHash = await spells.cast();
The cast() method returns a transaction hash that you can use to track the transaction status:
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"

Explore by topic

Dive deeper into DSA Connect capabilities

Core Concepts

Learn about DeFi Smart Accounts, spells, and how DSA Connect works under the hood

Multi-Chain Support

Deploy and manage Smart Accounts across Ethereum, Polygon, Arbitrum, and more

Casting Spells

Compose complex DeFi operations with the spell system

API Reference

Complete API documentation for all classes and methods

Connectors

Explore available DeFi protocol integrations

Account Management

Create, fetch, and manage multiple Smart Accounts

Key features

Everything you need to build sophisticated DeFi applications

Composable Transactions

Chain multiple DeFi operations across different protocols into a single atomic transaction using the spell system.

Multi-Chain Support

Deploy Smart Accounts on Ethereum, Polygon, Arbitrum, Optimism, Avalanche, Fantom, Base, and BSC with the same API.

Type-Safe TypeScript

Full TypeScript support with comprehensive type definitions for all methods, parameters, and return types.

Browser & Node.js

Works seamlessly in both browser environments with MetaMask and Node.js backends with private key management.

Ready to start building?

Create your first DeFi Smart Account and start composing complex transactions across protocols in minutes.

Get Started

Build docs developers (and LLMs) love