An interactive shell and command-line interface for dai.js
Last updated 2 years ago by bryanwb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install dai-shell 
SYNC missed versions from official npm registry.


An interactive shell and command-line interface for dai.js

oclif Version Downloads/week License


$ npm install -g dai-shell
running command...
$ dai (-v|--version|version)
dai-shell/0.0.6 linux-x64 node-v10.15.0
$ dai --help [COMMAND]
  $ dai COMMAND

Getting Started

Next, you will want to configure dai-shell with an account. Run the dai init command and a helpful wizard will walk you through adding your credentials. Note that dai-cli has the option to store the name of an environment variable to source your private key from. When you tell dai-cli to use an environment variable it only saves the name of that variable to disk and not your actual private key. dai init will also ask you for you infura API key. This value is written to disk.

Subsequent configuration changes can be made with the dai config subcommand. Of special interest is the ability to add multiple accounts with the dai config add subcommand and switch the default account with the dai config switch [accountName] subcommand.

Up and Running

Run dai shell to start a shell connected to a chain. Note that this is a customized node.js REPL w/ special pre-populated variables and support for the await keyword. All pre-populated variables are accessible from the ctx variable:

  • maker: instance of the Maker object connected to the chain specified during dai config add and with the current private key or mnemonic.
  • Maker: The big daddy Maker object
  • wallet: instance of wallet object created from the mnemonic/private key you specified and connected to a network
  • eth: a connection to Ethereum blockchain.
  • utils: utility functions from ethers

Here is an example shell session:

$ dai shell
Connecting to kovan - https://kovan.infura.io/[REDACTED]
dai> var cdp = await ctx.maker.openCdp()
dai> var result = await cdp.lockEth(0.1, ctx.Maker.ETH)
dai> result.receipt.blockNumber
dai> result.receipt.transactionHash
dai> cdp = await ctx.maker.getCdp(cdp.id)
dai> var v = await cdp.getCollateralValue()
dai> v.toString()
'0.10 ETH'
dai> result = await cdp.drawDai(5, ctx.Maker.DAI)
dai> var r = await cdp.getCollateralizationRatio()
dai> r

Author & License

Copyright 2019 Bryan W. Berry, MIT license

Current Tags

  • 0.0.8                                ...           latest (2 years ago)

3 Versions

  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (9)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |