The build() method creates a new DSA (DeFi Smart Account) on the blockchain. This method deploys a new smart contract wallet that can interact with various DeFi protocols through the Instadapp ecosystem.
import DSA from "dsa-connect";import Web3 from "web3";const web3 = new Web3(window.ethereum);const dsa = new DSA(web3, 1); // 1 for Ethereum mainnet// Build a new DSA with default settingsconst transaction = await dsa.build({ from: "0x...", // Your wallet address});console.log("DSA created! Transaction hash:", transaction.hash);
import DSA from "dsa-connect";import Web3 from "web3";const web3 = new Web3("https://mainnet.infura.io/v3/YOUR_INFURA_KEY");const dsa = new DSA( { web3: web3, mode: "node", privateKey: "YOUR_PRIVATE_KEY", }, 1);// Build a new DSA with custom authorityconst transaction = await dsa.build({ from: "0x...", authority: "0x...", // Address that will control the DSA origin: "0x...", // Your app's address for analytics version: 2, gas: 1000000, gasPrice: web3.utils.toWei("50", "gwei"),});console.log("DSA created! Transaction hash:", transaction.hash);
// Create a DSA where a different address has authorityconst transaction = await dsa.build({ from: "0xYourAddress...", authority: "0xAuthorityAddress...", // This address will control the DSA version: 2,});