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.
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 environmentconst web3 = new Web3(window.ethereum);const dsa = new DSA(web3, 1); // 1 = Ethereum mainnet// Node.js environmentconst 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 Accountconst txHash = await dsa.build();// Or fetch existing accountsconst accounts = await dsa.getAccounts(address);// Set the active accountawait 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 Aaveconst spells = dsa.Spell();spells.add({ connector: "aave-v2", method: "deposit", args: [ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH "1000000000000000000", // 1 ETH in wei 0, 0 ]});// Execute the spellconst txHash = await spells.cast();
View transaction response
The cast() method returns a transaction hash that you can use to track the transaction status: