Setup Account

DeFi Smart Account Setup

Every user needs to create Smart Account to interact with DeFi Protocols seamlessly; this allows developers to build extensible use-cases with maximum security and composability. You can also create multiple account for a single address.

  • Create Smart Account - build()
  • Fetch Smart Accounts - getAccounts()
  • Set Smart Account - setInstance()

build()

If the above function returns an empty array OR if a use-case requires you to create multiple accounts, trigger build() method.

dsa.build().then(console.log);

The build method also accepts an optional Object parameter as shown below:

dsa.build({
  gasPrice: gasPrice // estimated gas price
  origin: origin,
  authority: authority,
})
  • View our Gist for estimation of gas price.
ParameterTypeDescription
gasPricestring/numberThe gas price in gwei. Mostly used in Node implementation to configure the transaction confirmation speed.
originaddressThe address to track the origin of transaction. Used for analytics and affiliates.
authorityaddressThe DSA authority. The address to be added as authority.
fromaddressThe account with which you want to create your DSA. This is helpful to create DSA for other addresses.
noncestring/numberNonce of your sender account. Mostly used in Node implementation to send transaction with a particular nonce either to override unconfirmed transaction or some other purpose.

Returns

string: Transaction hash.

This creates a uniquely numbered Smart Account which acts as a proxy to interact with verified DeFi protocols and each DSA has a unique ethereum address.


getAccounts()

Fetch all the accounts owned by an ethereum address by calling getAccounts().

dsa.getAccounts(address).then(console.log);
ParameterTypeDescription
addressaddressAn ethereum address.

Returns

Array of Object with all the DSA where address is authorised:

[
  {
      id: 52, // DSA Number
      address: "0x...", // DSA Address
      version: 1 // DSA version
  },
  ...
]

setInstance()

Be sure to configure global values by calling setInstance(). You can get the id by calling getAccounts(). The configured account will be used for all subsequent calls.

dsa.setInstance(dsaId); // DSA ID
ParameterTypeDescription
dsaIdnumberThe DSA unique number.

Transfer Tokens

Now that you have an account setup, transfer assets to your DSA address, which can be eventually used as collateral, liquidity, et cetera in DeFi protocols. Developers can trigger the ETH / Token transfer by calling a SDK method - dsa.transfer(). Alternatively, call transfer() method from the respective ERC20 token contract.


If you still can't find something you're looking for or have any questions, ask them at our developers community on Telegram, Discord or simply send an Email.

Our team is excited about assisting you to build an application using Instadapp Developer Platform. Your questions and feedback help us make a better development environment for future developers.

Best way to stay connected with our progress.