An Intro To DaiJS

Build applications on top of MakerDao

Gaurav Agrawal
Apr 15, 2019 · 6 min read

First: What is MakerDao?

Think of Dai as an electronic dollar; a dollar on the Ethereum blockchain.

What is CDP?

Anyone who has collateral assets can leverage them to generate Dai on the Maker Platform through Maker’s unique smart contracts known as Collateralized Debt Positions. A Collateral Asset is a digital asset that the decentralized Maker Governance process has input into the system.

CDP using Dai JS

mkdir wallet
cd wallet
npm i ethereumjs-wallet
const Wallet = require('ethereumjs-wallet');
const wallet = Wallet.generate();
console.log("privateKey: " , wallet.getPrivateKeyString());
console.log("address: " , wallet.getAddressString());
cd && git clone https://github.com/buddies2705/integration-examples
cd integration-examples/react-example
cp .env.example .env
npm install
npm start
CDP in Action
const drawDaiAsync = (maker, cdp) => async dispatch => {//Getting default account
const defaultAccount = maker.service('token')
.get('web3').defaultAccount();
//Getting token
const dai = maker.service('token').getToken('DAI');
//Drawing CDP
const txn = await cdp.drawDai(0.1);
//checking Dai balance
const balance = await dai.balanceOf(defaultAccount);
console.log('Transaction from drawing Dai:', txn);console.log('Dai balance after drawing:', balance.toString());dispatch(daiDrawn());};

Wrapping Up

Open Finance Movement (#DeFi)

“Banking the Unbanked”

About QuikNode

QuikNode

Cloud-hosted Ethereum nodes for dApps, developers, and…

QuikNode

Cloud-hosted Ethereum nodes for dApps, developers, and power-users. Run a dedicated ETH node in minutes!

Gaurav Agrawal

Written by

Telegram @gaurav_zen , Editor — Coinmonks publication (medium.com/coinmonks) and working on (https://coincodecap.com)

QuikNode

Cloud-hosted Ethereum nodes for dApps, developers, and power-users. Run a dedicated ETH node in minutes!