Accounts

Overview

To use defire from an account, there is no need to do anything else but initialize defire library with that account. It is possible to create many defire instances, each on with a different account.
Javascript
1
const defire1 = Defire({ privateKey: "[PRIVATE KEY 1]" }, { network: 'rinkeby' });
2
const defire2 = Defire({ privateKey: "[PRIVATE KEY 2]" }, { network: 'rinkeby' });
3
const defire3 = Defire({ privateKey: "[PRIVATE KEY 3]" }, { network: 'rinkeby' });
Copied!
Visit this page for more information on how to initialize it.

Defire object

Object fields
address string
Address of the Defire main account

Assets query

A query to get the list of assets that Defire main account holds.
JavaScript & Node
1
const assets = await defire.query.getAssets();
Copied!
Returns
This method returns a Promise which resolves with anarray of string addresses of assets that Defire main account holds.

Asset balance query

A query to check Defire main account balance of an asset.
JavaScript & Node
1
const balance = await defire.query.balance(defire.Assets.DAI);
Copied!
Method parameters
address required string
Smart contract address of the asset.
Returns
This method returns a Promise which resolves with a BN object of the balance of the asset in wei.

Has an asset query

A query method to check if a Defire main account holds an asset.
JavaScript & Node
1
const result = await defire.query.hasAsset(defire.Assets.DAI);
Copied!
Method parameters
address required string
Smart contract address of the asset.
Returns
This method returns a Promise which resolves with true if Defire main account has the asset or false if not.

Execute single operation action

An action method that executes the operation from Defire main account.
JavaScript & Node
1
const result = await defire.actions.execute(operation);
Copied!
Method parameters
operation required operation object
DeFi operation to be executed.
Returns
This method returns a Promise which resolves with true if the operation execution succeeded or throws an error if it failed.

Execute multiple operations action

An action method to execute many DeFi operations from Defire main account.
JavaScript & Node
1
const result = await defire.actions.execute(
2
[operation1, operation2, operation3]
3
);
Copied!
Method parameters
operations required array of operation object
DeFi operations to be executed.
Returns
This method returns a Promise which resolves with true if the execution of all operations succeeded or throws an error if it failed.
Last modified 1yr ago