{"id":13785128,"url":"https://github.com/Kaisle/node-dai","last_synced_at":"2025-05-11T20:32:09.391Z","repository":{"id":65460394,"uuid":"139247069","full_name":"Kaisle/node-dai","owner":"Kaisle","description":"MakerDAO CDP management for Node.js and the browser","archived":false,"fork":false,"pushed_at":"2018-06-30T16:03:16.000Z","size":78,"stargazers_count":24,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-21T16:21:29.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kaisle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-30T12:18:19.000Z","updated_at":"2024-01-05T01:35:53.000Z","dependencies_parsed_at":"2023-01-24T14:45:21.497Z","dependency_job_id":null,"html_url":"https://github.com/Kaisle/node-dai","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaisle%2Fnode-dai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaisle%2Fnode-dai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaisle%2Fnode-dai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kaisle%2Fnode-dai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kaisle","download_url":"https://codeload.github.com/Kaisle/node-dai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253632087,"owners_count":21939371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T19:00:57.256Z","updated_at":"2025-05-11T20:32:09.091Z","avatar_url":"https://github.com/Kaisle.png","language":"JavaScript","funding_links":[],"categories":["Developer Resources","Libraries"],"sub_categories":["Single-Collateral Dai","Self-hosted"],"readme":"# node-dai\n\n* Deposit ETH to your CDP and draw DAI.\n* Convert your DAI to ETH.\n* Fund your CDP with PETH.\n* Draw DAI from your CDP.\n* And much more...\n\nThe first comprehensive NPM module for the MakerDAO ecosystem.\n\nOffers 14 different actions for programatically interacting with MakerDAO using Javascript and web3.\n\n[What is MakerDAO?](https://medium.com/cryptolinks/maker-for-dummies-a-plain-english-explanation-of-the-dai-stablecoin-e4481d79b90)\n\n## Installation\n\n```node\nnpm install node-dai --save\n```\n## Prerequisites\n\n* An open CDP\n* All token allowances approved\n* A little bit of MKR in your wallet (for paying fees)\n\nThe first two can be obtained in a few minutes by heading to the MakerDAO dashboard: https://dai.makerdao.com/\n\nMKR can be bought at OasisDEX: https://oasisdex.com/trade/MKR/DAI\n\nAlternatively you can use a [public test account](#public-test-account) that is set up for use already.\n\n## Examples\n\n#### Deposit 1 ETH to CDP and draw 300 DAI:\n\n```node\nconst nodeDai = require('node-dai');\n\nvar options = {\n  privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', // Your private key\n  cdpId: 614, // The ID of your open CDP\n  networkId: 42, // Kovan Test Network, use 1 for Main Network\n  DAIToDraw: 300 // Amount of DAI to draw from CDP\n};\nvar ETH = 1;\n\n(async function(){\n  await nodeDai.ETHToDAI(ETH, options);\n})();\n\n```\n\n#### Convert 200 DAI to ETH:\n\n```node\nconst nodeDai = require('node-dai');\n\nvar options = {\n  privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', // Your private key\n  cdpId: 614, // The ID of your open CDP\n  networkId: 42 // Kovan Test Network, use 1 for Main Network\n};\nvar DAI = 200;\n\n(async function(){\n  await nodeDai.DAIToETH(DAI, options);\n})();\n\n```\n\n#### Draw 200 DAI from CDP:\n\n```node\nconst nodeDai = require('node-dai');\n\nvar options = {\n  privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', // Your private key\n  cdpId: 614, // The ID of your open CDP\n  networkId: 42 // Kovan Test Network, use 1 for Main Network\n};\nvar DAI = 200;\n\n(async function(){\n  await nodeDai.CDPToDAI(DAI, options);\n})();\n\n```\n\n#### Deposit 200 DAI to CDP:\n\n```node\nconst nodeDai = require('node-dai');\n\nvar options = {\n  privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', // Your private key\n  cdpId: 614, // The ID of your open CDP\n  networkId: 42 // Kovan Test Network, use 1 for Main Network\n};\nvar DAI = 200;\n\n(async function(){\n  await nodeDai.DAIToCDP(DAI, options);\n})();\n\n```\n\n#### Convert 1 PETH to ETH:\n\n```node\nconst nodeDai = require('node-dai');\n\nvar options = {\n  privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', // Your private key\n  networkId: 42 // Kovan Test Network, use 1 for Main Network\n};\nvar PETH = 1;\n\n(async function(){\n  await nodeDai.PETHToETH(PETH, options);\n})();\n\n```\n\n#### Draw 1 PETH from CDP and convert to 1 ETH:\n\n```node\nconst nodeDai = require('node-dai');\n\nvar options = {\n  privateKey: 'c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', // Your private key\n  cdpId: 614, // The ID of your open CDP\n  networkId: 42 // Kovan Test Network, use 1 for Main Network\n};\nvar PETH = 1;\n\n(async function(){\n  await nodeDai.CDPToETH(PETH, options);\n})();\n\n```\n\n## API\n\n* *Deposit ETH and withdraw DAI:* ```nodeDai.ETHToDAI (ETH, options)```\n\n* *DAI to ETH:* ```nodeDai.DAIToETH (DAI, options)```\n\n* *ETH to WETH:* ```nodeDai.ETHToWETH (ETH, options)```\n\n* *WETH to PETH:* ```nodeDai.WETHToPETH (WETH, options)```\n\n* *PETH to CDP:* ```nodeDai.PETHToCDP (PETH, options)```\n\n* *Draw DAI:* ```nodeDai.CDPToDAI (DAI, options)```\n\n* *Repay DAI:* ```nodeDai.DAIToCDP (DAI, options)```\n\n* *Withdraw PETH from CDP:* ```nodeDai.CDPToPETH (PETH, options)```\n\n* *PETH to WETH:* ```nodeDai.PETHToWETH (PETH, options)```\n\n* *WETH to ETH:* ```nodeDai.WETHToETH (WETH, options)```\n\n* *CDP to ETH:* ```nodeDai.CDPToETH (ETH, options)```\n\n* *PETH to ETH:* ```nodeDai.PETHToETH (PETH, options)```\n\n* *WETH to DAI:* ```nodeDai.WETHToDAI (WETH, options)```\n\n* *PETH to DAI:* ```nodeDai.PETHToDAI (PETH, options)```\n\n\n## Options\n\n```json\n    privateKey: Your private key, used for signing transactions. All transactions are signed locally.\n    cdpId: The numeric ID of one of your open CDPs (e.g. 614)\n    networkId: The ID of the desired network. 1 for Main Network, 42 for Kovan Test Network. Default: 42\n    DAIToDraw: Amount of DAI to draw from your CDP. Only relevant for methods: ETHToDAI, WETHToDAI, PETHToDAI\n    web3: An optional web3 instance. Must be version 0.20.6 or lower of web3. Version 1.x.x of web3 is currently not supported.\n    verbose: Whether to print to console or not. Default: true\n    waitInterval: Amount of ms to wait inbetween transactions. Default:  10000\n    gasLimit: Gas Limit for every transaction. Default:  300000\n    requireConfirm: Require that every transaction receives 12 block confirmations before proceeding to next. Default: false\n```\n\n## Networks\n\n* Main Network (network ID 1)\n* Kovan Test Network (network ID 42)\n\nIt is recommended to test the module on Kovan first, before using it with the Main Network.\n\nMore test networks will be added soon.\n\n## Public test account\n\nIf you prefer not to use your own account, you may instead use the Ganache mock account with\n\n```json\n  privateKey: c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3\n  seed: candy maple cake sugar pudding cream honey rich smooth crumble sweet treat\n```\n\nThis account is public, has an open CDP, some MKR and Kovan-ETH in its wallet and has set all permissions. It can be used for fast testing.\n\n**DO NOT SEND REAL FUNDS TO THIS ACCOUNT. USE FOR TESTING ONLY.**\n\n## Troubleshooting\n\n* Ensure that you have enough MKR to pay the small fee necessary for interacting with a CDP.\n* Ensure that you have enough ETH to pay for gas.\n* Ensure that you have an open CDP and that you have passed along its ID in the options object.\n* Ensure that you have set all permissions in the MakerDAO dashboard (WETH Join, WETH Mock, PETH Exit/Lock, PETH Boom, MKR Wipe/Shut, DAI Wipe/Shut, DAI Bust/Cash) .\n* Ensure that you are on the right network (Kovan is the default network, pass along 1 as networkId to use the Main Network instead).\n* Ensure that your private key is valid.\n* If using a custom web3 instance, ensure that it is valid and is configured to use the right network. You can use Infura for easy access: https://infura.io/\n* Ensure that you are not overleveraging your CDP. You must always leave some collateral (PETH) behind when drawing DAI.\n\nThe MakerDAO dashboard can be accessed here: https://dai.makerdao.com/\n\n## License\n\nCopyright 2018 Kaisle\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n## Additional resources\n\nFor more information about MakerDAO visit: https://makerdao.com/\n\nAccess the MakerDAO dashboard at: https://dai.makerdao.com/\n\nAccess OasisDEX at: https://oasisdex.com/trade/MKR/DAI\n\n## Contributing\n\n```bash\n  git clone https://github.com/Kaisle/node-dai.git \u0026\u0026 cd node-dai\n  npm install\n```\n\nThis module is still in its infancy. Any pull requests are welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKaisle%2Fnode-dai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKaisle%2Fnode-dai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKaisle%2Fnode-dai/lists"}