Overview
TheDSA class is the main entry point for interacting with Instadapp’s DeFi Smart Accounts (DSA). It provides methods for building DSAs, casting spells, and managing account instances.
Constructor
A Web3 instance or DSAConfig object. See Configuration for details.
The blockchain network ID. Supported chains: 1 (Ethereum), 137 (Polygon), 42161 (Arbitrum), 43114 (Avalanche), 10 (Optimism), 250 (Fantom), 8453 (Base), 9745 (Plasma), 56 (BSC)
Configuration options for the DSA instance
Skip chain ID validation against the Web3 provider
Properties
Static Properties
The current version of the DSA SDK
Instance Properties
The configuration object used to initialize the DSA instance
The Web3 instance used for blockchain interactions
The current operation mode
The origin address for affiliation and on-chain analytics. Defaults to genesis address.
Maximum uint256 value:
115792089237316195423570985008687907853269984665640564039457584007913129639935Extension Properties
ERC20 token utility methods
ERC20 Euler-specific token utility methods
ERC721 NFT utility methods
Internal utility methods for encoding and transaction management
Helper methods for spell casting operations
Transaction management methods
Instapool V2 resolver methods
Avocado wallet integration methods
DSA account management methods
Core Methods
setOrigin()
Sets the origin address for affiliation and on-chain analytics.The origin address to set
setInstance()
Sets the current DSA instance by ID.The DSA ID to set as the current instance
The instance details including id, address, version, and chainId
setAccount()
Alias forsetInstance(). Sets the current DSA ID instance.
DSA ID
The instance details
getAccountIdDetails()
Retrieves details for a specific DSA instance ID.The DSA instance ID to query
Object containing id, address, version, and chainId
refreshChainId()
Refreshes the chain ID from the Web3 provider and updates the instance.Completes when chain ID is updated
Building DSA Accounts
build()
Builds a new DSA account and executes the transaction.Build parameters
Authority address for the DSA. Defaults to current address.
Origin address for analytics. Defaults to genesis address.
DSA version. Defaults to 2.
Transaction sender address
Gas limit for the transaction
Gas price (required in node mode)
Maximum fee per gas (EIP-1559)
Maximum priority fee per gas (EIP-1559)
Transaction nonce
Callback executed when transaction receipt is received
params.onConfirmation
(confirmationNumber: number, receipt: TransactionReceipt, latestBlockHash?: string) => void
Callback executed on each confirmation
Transaction hash
buildTxObj()
Builds a new DSA transaction object without sending it.Build parameters (authority and from are required)
Transaction configuration object that can be signed and sent manually
buildTransactionConfig()
Builds a transaction configuration for creating a new DSA.Configuration parameters
Authority address
Origin address
Sender address
Gas price
Maximum fee per gas
Maximum priority fee per gas
Gas limit
Transaction nonce
Transaction configuration
Spell Casting
Spell()
Creates a new Spells instance for building and executing DeFi operations.A Spells instance with fluent API for adding operations
add(spell)- Add a spell to the sequencecast(params?)- Execute all spellsestimateCastGas(params?)- Estimate gas for executionencodeCastABI(params?)- Encode spells to ABIencodeSpells(params?)- Encode spells dataconvertToAvocadoActions()- Convert spells to Avocado actions
cast()
Executes spells on the current DSA instance.Either a Spells instance or CastParams object
The Spells instance to cast
Origin address
Target DSA address. Defaults to current instance.
Sender address
ETH value to send with transaction
Gas limit
Gas price
Maximum fee per gas
Maximum priority fee per gas
Transaction nonce
Receipt callback
params.onConfirmation
(confirmationNumber: number, receipt: TransactionReceipt, latestBlockHash?: string) => void
Confirmation callback
Transaction hash
castData()
Executes pre-encoded cast data on the current DSA instance.Either cast data string or CastDataParams object
Pre-encoded cast calldata
Origin address
Target DSA address
Sender address
ETH value
Gas limit
Gas price
Maximum fee per gas
Maximum priority fee per gas
Transaction nonce
Receipt callback
params.onConfirmation
(confirmationNumber: number, receipt: TransactionReceipt, latestBlockHash?: string) => void
Confirmation callback
Transaction hash
Alias Methods
encodeSpells()
Alias fordsa.internal.encodeSpells(). Encodes spells into targets and calldata arrays.
sendTransaction()
Alias fordsa.transaction.send(). Sends a transaction.
count()
Alias fordsa.accounts.count(). Returns the total number of DSA accounts.
getAccounts()
Alias fordsa.accounts.getAccounts(). Retrieves DSA accounts for an address.
getAuthById()
Alias fordsa.accounts.getAuthoritiesById(). Gets authorities for a DSA by ID.
encodeCastABI()
Alias fordsa.castHelpers.encodeABI(). Encodes cast ABI.
estimateCastGas()
Alias fordsa.castHelpers.estimateGas(). Estimates gas for casting spells.
convertToAvocadoActions()
Alias fordsa.avocado.convertToActions(). Converts spells to Avocado wallet actions.
maxVal()
Returns the maximum uint256 value as a string.Maximum uint256 value