Getting started

Defire's javascript library

Installation

Defire is released under the MIT license & supports modern environments

Javascript & Node
Javascript & Node

Download

Installation

In a browser:

<script src="defire.min.js"></script>

Using npm:

npm install defire

Using yarn

yarn add defire

In Node.js

const Defire = require("defire");

Initialization

A Defire instance is always associated with an Ethereum account, known as Defire main account, and currently there are two ways to initialize it. One way is to use the account's private key and the other one is with an account connector object.

The Ethereum account used to initialize Defire instance is called "Main Defire account".

Initializing with a private key

Initialize the library using an Ethereum account private key.

Javascript & Node
Javascript & Node
const defire = Defire({
privateKey: "c6cbd7d76bc5baca530c875663711b947efa6a86a900a9e8645ce32e5821484e",
}, { network: "rinkeby" });

Method parameters

mainAccount required object :

  • privateKey required string (Ethereum private key of the main account to use)

  • provider optional provider (Web3 provider)

Params to load the main account from a private key

options optional object

  • network optional string (Ethereum network: "rinkeby" | "mainnet". Default "rinkeby')

  • gasPrice optional number (Gas price in gwei)

  • gasLimit optional number (Gas limit)

Configuration options for Defire Platform.

Initializing with Ethereum APIs

Initialize the library using Web3.js, Ethers.js or Eth.js.

Web3.js
Ethers.js
Eth.js
Web3.js
const defire = Defire({
web3js: web3,
address: "0xC257274276a4E539741Ca11b590B9447B26A8051"
}, { network: "rinkeby" });

Method parameters

mainAccount required object :

  • web3js required Web3.js object (Ethereum API object)

  • address required string (Ethereum address of the main account to use)

Params to load the main account from a private key

options optional object

  • network optional string (Ethereum network: "rinkeby" | "mainnet". Default "rinkeby')

  • gasPrice optional number (Gas price in gwei)

  • gasLimit optional number (Gas limit)

Configuration options for Defire Platform.

Ethers.js
const defire = Defire({
ethersjs: ethers,
address: "0xC257274276a4E539741Ca11b590B9447B26A8051"
}, { network: "rinkeby" });

Method parameters

mainAccount required object :

  • ethersjs required Ethers.js object (Ethereum API object)

  • address required string (Ethereum address of the main account to use)

Params to load the main account from a private key

options optional object

  • network optional string (Ethereum network: "rinkeby" | "mainnet". Default "rinkeby')

  • gasPrice optional number (Gas price in gwei)

  • gasLimit optional number (Gas limit)

Configuration options for Defire Platform.

Eth.js
const defire = Defire({
ethjs: eth,
address: "0xC257274276a4E539741Ca11b590B9447B26A8051"
}, { network: "rinkeby" });

Method parameters

mainAccount required object :

  • ethjs required Eth.js object (Ethereum API object)

  • address required string (Ethereum address of the main account to use)

Params to load the main account from a private key

options optional object

  • network optional string (Ethereum network: "rinkeby" | "mainnet". Default "rinkeby')

  • gasPrice optional number (Gas price in gwei)

  • gasLimit optional number (Gas limit)

Configuration options for Defire Platform.

For initializing with other Ethereum APIs, check custom connectors page