# Single-Collateral Sai

## Installation

Single-Collateral Dai support in Dai.js is implemented as a [plugin](/build/dai.js/maker/plugins.md). The SCD plugin is also available as an [npm](https://www.npmjs.com/package/@makerdao/dai-plugin-scd) package and its source code can be found on [Github](https://github.com/makerdao/dai.js/tree/dev/packages/dai-plugin-scd).

`npm install @makerdao/dai-plugin-scd`

```javascript
import { ScdPlugin } from '@makerdao/dai-plugin-scd';
// or
const { ScdPlugin } = require('@makerdao/dai-plugin-scd');
```

## Quick example

The code below creates a CDP, locks ETH into it, and draws out Sai.

```javascript
import Maker from '@makerdao/dai';
import { ScdPlugin } from '@makerdao/dai-plugin-scd';

async function openLockDraw() {
  const maker = await Maker.create("http", {
    plugins: [ScdPlugin],
    privateKey: YOUR_PRIVATE_KEY,
    url: 'https://kovan.infura.io/v3/YOUR_INFURA_PROJECT_ID'
  });

  await maker.authenticate();
  const cdpService = await maker.service('cdp');
  const cdp = await cdpService.openCdp();

  await cdp.lockEth(0.25);
  await cdp.drawSai(50);

  const debt = await cdp.getDebtValue();
  console.log(debt.toString); // '50.00 SAI'
}

openLockDraw();
```

The services and objects below are used to work with Single-Collateral Sai.

* [CDP Service](/build/dai.js/single-collateral-dai/eth-cdp-service.md)
* [Collateralized Debt Position](/build/dai.js/single-collateral-dai/collateralized-debt-position.md)
* [System Status](/build/dai.js/single-collateral-dai/system-status.md)
* [Token Conversion](/build/dai.js/single-collateral-dai/token-conversion.md)

## openCdp()

* **Returns:** promise (resolves to new CDP object once mined)

`openCdp()` will create a new CDP, and then return the CDP object, which can be used to access other CDP functionality. The promise will resolve when the transaction is mined.

```javascript
const cdpService = await maker.service('cdp');
const newCdp = await cdpService.openCdp();
```

## getCdp(int id)

* **Returns:** promise (resolves to CDP object)

`getCdp(id)` creates a CDP object for an existing CDP. The CDP object can then be used to interact with your CDP.

```javascript
const cdpService = await maker.service('cdp');
const cdp = await cdpService.getCdp(614);
```

Once you have an instance of a CDP, you can use [CDP instance methods](/build/dai.js/single-collateral-dai/collateralized-debt-position.md) to read its state and perform actions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.makerdao.com/build/dai.js/single-collateral-dai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
