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
Javascript
const defire1 = Defire({ privateKey: "[PRIVATE KEY 1]" }, { network: 'rinkeby' });
const defire2 = Defire({ privateKey: "[PRIVATE KEY 2]" }, { network: 'rinkeby' });
const defire3 = Defire({ privateKey: "[PRIVATE KEY 3]" }, { network: 'rinkeby' });

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
JavaScript & Node
const assets = await defire.query.getAssets();

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
JavaScript & Node
const balance = await defire.query.balance(defire.Assets.DAI);

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
JavaScript & Node
const result = await defire.query.hasAsset(defire.Assets.DAI);

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
JavaScript & Node
const result = await defire.actions.execute(operation);

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
JavaScript & Node
const result = await defire.actions.execute(
[operation1, operation2, operation3]
);

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.