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
orwindow.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.
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.If this is omitted and the provider does not have an unlocked account, the
maker
object will start in read-only mode.
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
Number of blocks to wait after a transaction has been mined when calling
confirm
. See Transactions for further explanation.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 runawait maker.authenticate()
before using any other methods.
Instance methods
service()
Returns: service object
Return a service instance that was included in this instance of maker
.
Services
The MCD plugin defines several services for working with Multi-Collateral Dai. Review Getting started to see how to add the plugin.
'mcd:cdpManager'
: for working with Vaults.'mcd:cdpType'
: for reading parameters and live data (totals and prices) for collateral types.'mcd:savings'
: for working with the Dai Savings Rate.'mcd:systemData'
: for reading system-wide parameters.
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.
You can start in read-only mode and still add an account with the ability to sign transactions later on.
Last updated