# Configurations

Developers can develop wallet application using our cli sdk. Install the `dcent-cli-connector` from npm repository.

```
npm install dcent-cli-connector
```

Developer can access api through `DcentCLIConnector` object.

```
import DcentCLIConnector from 'dcent-cli-connector'
```

### Requirement

* Must have a `D'CENT Biometric wallet`.\
  You can get it at D'CENT website : <https://dcentwallet.com/Shop>
* D'CENT Biometric will be connected with your PC or Labtop using USB Cable(Micro USB 5-pin type).

## Basic structure

### Functions

All API functions return a `Promise`.\
When function processing is completed, it is resolved. If an error occurs, it is rejected.\
In either case, respond with a JSON object.

### Returned JSON object type

```json
{
    "header": {
        "version": "1.0",
        "request_from": "",
        "status": ""
    },
    "body": {
        "command" : "",
        "parameter" : {}
    }
}
```

### Common Errors

If D'CENT wallet isn't connected via USB, you'll get the following error:

```json
{
    "header": {
        "version": "1.0",
        "request_from": "wam",
        "status": "error"
    },
    "body": {
        "error": {
            "code": "no_device",
            "message": "D'CENT Biometric Wallet is not connected"
        }
    }
}
```

When executing a function that requires user authentication, an error occurs if the user cancels the authentication. The following shows the user cancel error in the Ethereum signed Transaction.

```json
{
    "header": {
        "version": "1.0",
        "request_from": "ethereum",
        "status": "error"
    },
    "body": {
        "command": "transaction",
        "error": {
            "code": "user_cancel",
            "message": "user cancel"
        }
    }
}
```

## Basic functions

### `DcentCliConnector` initialize

`dcent-cli-connector` provides functions for using D'CENT Biometric Wallet.

```javascript
var result
try{
    result = await DcentCLIConnector.info()
}catch(e){
    result = e
}
```

`info()` returns :

```json
{
    "header": {
        "version": "1.0",
        "request_from": "",
        "status": ""
    },
    "body": {
        "command" : "",
        "parameter" : {
            "version": "1.0.0",
            "isUsbAttached": "true | false"
        }
    }    
}
```

### Set TimeOut Time

Sets the maximum time the function will run. Once set the timeout Time, it is valid until the value is set again. The default value is 60 seconds.

You can set the timeout time by calling `setTimeOutMs ()` as shown below.

```json

  try {
    await DcentCLIConnector.setTimeOutMs(60000) // 60 sec, The default value is 60 seconds.
  } catch (e) {
    console.log(e)    
  }
```

All functions except setTimeOutMs function are called and then respond with `JSON Object` as below when timeout occurs.

```json
  {
    "header": {
      "version": "1.0",
      "response_from": "dcent-cli",
      "status": "error"
    },
    "body": {
      "error": {
        "code": "time_out",
        "message": "The function execution time has expired"
      }
    }
  }
```


---

# 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://dev-docs.dcentwallet.com/dcent-biometric-wallet-for-pc/dcent-cli-connector/configurations.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.
