> For the complete documentation index, see [llms.txt](https://dev-docs.dcentwallet.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-docs.dcentwallet.com/dcent-biometric-wallet-for-pc/dcent-web-connector/address-and-xpub.md).

# Address & XPUB

## Get Address

You can get address of account using `getAddress()` function.

```javascript
var coinType = DcentWebConnector.coinType.ETHEREUM
var keyPath = "m/44'/60'/0'/0/0" // key path of the account

var result
try{
    // Get Ethereum Address corresponding to keyPath
    result = await DcentWebConnector.getAddress(coinType, keyPath)
}catch(e){
    result = e
}
```

Returned response object has:

```json
{
    "header": {
        "version": "1.0",
        "response_from": "ethereum",
        "status": "success"
    },
    "body": {
        "command": "get_address",
        "parameter": {
            "address": "0x354609C4c9a15d4265cF6D94010568D5Cf4d0c1B"
        }
    }
}
```

The address string format is depend on the coin type.

For ss58 addresses used by the Substrate ecosystems such as Astar, prefix is added. The value of prefix is the prefix for each network defined in [ss58-registry](https://github.com/paritytech/ss58-registry).

```javascript
var coinType = DcentWebConnector.coinType.PARA
var keyPath = "m/44'/810'/0'/0/0" // key path of the Astar's account
var prefix = 5 // The address prefix of Astar

var result
try{
    // Get the address corresponding to keyPath & prefix
    result = await DcentWebConnector.getAddress(coinType, keyPath, prefix)
}catch(e){
    result = e
}
```

Please note that `Astar EVM` features an EVM (Ethereum Virtual Machine) compatible runtime environment, so it is the same as getting the address of ETHEREUM account.

Returned response object has:

```json
{
    "header": {
        "version": "1.0",
        "response_from": "para",
        "status": "success"
    },
    "body": {
        "command": "get_address",
        "parameter": {
            "address": "YzsEz5dG8TDqG49pGaejLrFoD4oeNTEX7yWt4qcCV4TA9LB"
        }
    }
}
```

## Get XPUB

You can get xpub using `getXPUB()` function. The BIP32 key path must be at least 2 depth or more.

```javascript
var keyPath = "m/44'/0'" // key path of the account

var result
try{
    // Get extended public key corresponding to keyPath
    result = await DcentWebConnector.getXPUB(keyPath)
}catch(e){
    result = e
}
```

Returned response object has:

```json
{
    "header": {
        "version": "1.0",
        "response_from": "coin",
        "status": "success"
    },
    "body": {
        "command": "xpub",
        "parameter": {
            "public_key": "xpub6Bp87egy.....EdAH4sMeqY3"
        }
    }
}
```

The public\_key is xpub value.

## Select Address

Show you address list and you can select an address using `selectAddress()` function.

```javascript
var result
try{
    // Get extended public key corresponding to keyPath
    let addresses = [
        {
            address: '0x1234567812345678123456781234567812345678',
            path: `m'/44'/60'/0'/0/0`
        },
        {
            address: '0xabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd',
            path: `m'/44'/8217'/0'/0/0`
        }
    ]
    result = await DcentWebConnector.selectAddress(addresses)
}catch(e){
    result = e
}
```

Returned response object has:

```json
{
    "header": {
        "version": "1.0",
        "response_from": "bridge",
        "status": "success"
    },
    "body": {
        "command": "select_address",
        "parameter": {
            "selected_index": 0,
            "selected_address": {
                "address": "0x1234567812345678123456781234567812345678",
                "path": "m'/44'/60'/0'/0/0"
            }
        }
    }
}
```

The 'selectedIndex' is index of addresses array.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://dev-docs.dcentwallet.com/dcent-biometric-wallet-for-pc/dcent-web-connector/address-and-xpub.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
