Maker Protocol Technical Docs
  • MakerDAO Technical Docs
  • Getting Started
    • Maker Protocol 101
  • Smart Contract Modules
    • Dai Module
      • Dai - Detailed Documentation
    • Core Module
      • Vat - Detailed Documentation
      • Spot - Detailed Documentation
    • Collateral Module
      • Join - Detailed Documentation
    • Liquidation 2.0 Module
    • System Stabilizer Module
      • Flapper - Detailed Documentation
      • Flopper - Detailed Documentation
      • Vow - Detailed Documentation
    • Oracle Module
      • Oracle Security Module (OSM) - Detailed Documentation
      • Median - Detailed Documentation
    • MKR Module
    • Governance Module
      • Spell - Detailed Documentation
      • Pause - Detailed Documentation
      • Chief - Detailed Documentation
    • Rates Module
      • Pot - Detailed Documentation
      • Jug - Detailed Documentation
    • Proxy Module
      • Proxy Actions - Detailed Documentation
      • Vote Proxy - Detailed Documentation
      • CDP Manager - Detailed Documentation
      • DSR Manager - Detailed Documentation
    • Flash Mint Module
    • Maker Protocol Emergency Shutdown
      • Emergency Shutdown for Partners
      • The Emergency Shutdown Process for Multi-Collateral Dai (MCD)
      • End - Detailed Documentation
      • ESM - Detailed Documentation
  • Glossary
    • MCD Glossaries
    • Smart Contract Annotations
  • Deployment Addresses
    • Maker Protocol Deployments
  • Security
    • Security for the Maker Protocol
  • Building on top of the Maker Protocol
    • Developer Guides and Tutorials
    • The Dai Javascript Library of the Maker Protocol
      • Getting started
      • Configuration
        • Plugins
      • Vault manager
      • Collateral types
      • Dai Savings Rate
      • Currency units
      • System data
      • Advanced
        • Transaction manager
        • DSProxy
        • Events
        • Using multiple accounts
        • Adding a new service
      • Single-Collateral Sai
        • Collateralized Debt Position
        • CDP Service
        • Price Service
        • System Status
        • Tokens
        • Token Conversion
        • Exchange Service
    • Pymaker
  • Keepers
    • The Auctions of the Maker Protocol
    • Auction Keepers
      • Auction Keeper Bot Setup Guide
    • Market Maker Keepers
      • Market Maker Keeper Bot Setup Guide
    • Cage Keeper
    • Simple Arbitrage Keeper
    • Chief Keeper
  • Command-line Interfaces
    • Seth
    • Multi Collateral Dai (MCD) CLI
    • Dai and Collateral Redemption during Emergency Shutdown
    • Emergency Shutdown (ES) CLI
  • Miscellaneous
    • Liquidations 1.2 System (Deprecated)
      • Cat - Detailed Documentation
      • Flipper - Detailed Documentation
    • SCD <> MCD Migration
    • Upgrading to Multi-Collateral Dai Guide
Powered by GitBook
On this page
  • Maker.create
  • Presets
  • Options
  • Instance methods
  • service()
  • Services
  • Read-only mode
Export as PDF
  1. Building on top of the Maker Protocol
  2. The Dai Javascript Library of the Maker Protocol

Configuration

Maker.create

You can configure the behavior of Dai.js by passing different arguments to Maker.create. The first argument is the name of a preset, and the second is an options object.

Presets

  • 'browser'

    • Use this preset when using the library in a browser environment. It will attempt to connect using window.ethereum or window.web3.

  • 'http'

    • Connect to a JSON-RPC node. Requires url to be set in the options.

  • 'test'

    • Use a local node (e.g. Ganache) running at http://127.0.0.1:2000, and sign transactions using node-managed keys.

const makerBrowser = await Maker.create('browser');

const makerHttp = await Maker.create('http', {
  url: 'https://kovan.infura.io/v3/YOUR_INFURA_PROJECT_ID'
});

const makerTest = await Maker.create('test');

Options

  • privateKey

    • Optional. The private key used to sign transactions. If this is omitted, the first account available from the Ethereum provider will be used. Only used with the 'http' preset.

  • url

    • The URL of the node to connect to. Only used with the 'http' preset.

  • web3.transactionSettings

    • Object containing transaction options to be applied to all transactions sent through the library.

    • Default value: { gasLimit: 4000000 }

  • web3.confirmedBlockCount

    • Default value: 5

  • web3.inject

    • For advanced users. You can inject your own custom instance of a Web3 provider with this, instead of using the default HttpProvider.

  • log

    • Set this to false to reduce the verbosity of logging.

  • autoAuthenticate

    • Set this to false to create the Maker instance without connecting yet. If so, you must run await maker.authenticate() before using any other methods.

// It doesn't necessarily make sense to set all these
// options at the same time (e.g. `url` and `inject`),
// this is just meant to illustrate the shape of the
// options object.
const maker = await Maker.create('http', {
  privateKey: YOUR_PRIVATE_KEY, // '0xabc...'
  url: 'http://some-ethereum-rpc-node.net',
  web3: {
    statusTimerDelay: 2000,
    confirmedBlockCount: 8
    transactionSettings: {
      gasPrice: 12000000000
    },
    inject: someProviderInstance
  },
  log: false,
  autoAuthenticate: false
});

Instance methods

service()

  • Returns: service object

Return a service instance that was included in this instance of maker.

const accountsService = maker.service('accounts');

Services

Read-only mode

As mentioned above, the Maker instance can be used in read-only mode, if you just want to read data from the blockchain without signing any transactions. Simply omit the privateKey option.

PreviousGetting startedNextPlugins

Last updated 4 years ago

If this is omitted and the provider does not have an unlocked account, the maker object will start in .

Number of blocks to wait after a transaction has been mined when calling confirm. See for further explanation.

The MCD plugin defines several services for working with Multi-Collateral Dai. Review to see how to add the plugin.

: for working with Vaults.

: for reading parameters and live data (totals and prices) for collateral types.

: for working with the Dai Savings Rate.

: for reading system-wide parameters.

You can start in read-only mode and still with the ability to sign transactions later on.

read-only mode
Transactions
Getting started
'mcd:cdpManager'
'mcd:cdpType'
'mcd:savings'
'mcd:systemData'
add an account