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.
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 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
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.
Last updated