How to setup DAI for local development

Matthew Black
2 min readJun 3, 2018

--

3 years ago, MakerDAO was first formed, with the vision of creating a much needed stablecoin in the ecosystem. 5 months ago, DAI was launched on mainnet.

In this tutorial, we’ll go over the process of setting up SAI (Single Collateral DAI) for local development

(Note this tutorial is for Mac users)

  1. Install Dapp Toolkit
curl https://nixos.org/nix/install | sh
nix-channel --add https://nix.dapphub.com/pkgs/dapphub
nix-channel --update
nix-env -iA dapphub.{dapp,seth,hevm,evmdis}

2. Clone the SAI repo

git clone https://github.com/makerdao/saicd sai

3. Run the dapp testnet

dapp testnet

Note the (default) account which is:

fd5c42978bebaa67f850ded1124f982010acd229

We’ll need this later

(If you’re having trouble with this step check out https://medium.com/dapphub/easy-local-testnets-for-your-dapp-b9786ca80c88 )

4. To make sure we don’t have to add passphrase every time, we can create an empty passphrase file in a new terminal tab

touch emptyphrase

5. In this new terminal tab window export required variables

export ETH_PASSWORD=$PWD/emptypassexport ETH_KEYSTORE=~/.dapp/testnet/8545/keystore

And also export the (default) account from above

export ETH_FROM=fd5c42978bebaa67f850ded1124f982010acd229

6. Now run the deploy-fab and deploy scripts in /bin

./bin/deploy-fab && . load-fab-* && ./bin/deploy && . load-env-*

For context, the deploy-fab script deploys local contracts gem (externally valuable token e.g. ETH contract), vox (target price contract), tub (cup manager contract), tap (liquidator contract), top (global settlement manager contract), mom (admin manager contract), dad (authority contract) and the deploy script deploys the dai contract.

7. Lastly we’ll need to set some default parameters

Let’s set the eth price, mkr price

seth send $SAI_PIP "poke(bytes32)" $(seth --to-uint256 $(seth --to-wei 300 ETH))
seth send $SAI_PEP "poke(bytes32)" $(seth --to-uint256 $(seth --to-wei 220 ETH))

We’ll also and generate some gem (ETH) and some gov (MKR).

seth send $SAI_GEM "mint(uint256)" $(seth --to-uint256 $(seth --to-wei 2000000 ETH))
seth send $SAI_GOV "mint(uint256)" $(seth --to-uint256 $(seth --to-wei 1000000 ETH))

We will also set the debt ceiling, the liquidation ratio to 150% and the liquidation penalty to 20%.

seth send $SAI_MOM "setCap(uint256)" $(seth --to-uint256 $(seth --to-wei 50000000 ETH))
seth send $SAI_MOM "setMat(uint256)" $(seth --to-uint256 $(seth --to-wei 1500000000 ETH))
seth send $SAI_MOM "setAxe(uint256)" $(seth --to-uint256 $(seth --to-wei 1200000000 ETH))

All set!

For a more detailed instructions on developing with DAI be sure to look at https://github.com/makerdao/sai/blob/master/DEVELOPING.md

--

--