# Resolving CSPR.name

CSPR.cloud REST API provides the possibility to resolve CSPR.name names either directly by calling the [CSPR.name Resolution API](https://docs.cspr.cloud/1.4.x/rest-api/cspr-name-resolution) or by including CSPR.name names as [optional properties](https://docs.cspr.cloud/1.4.x/documentation/overview/optional-properties).

At the moment of writing this page (August 27th, 2024), the CSPR.name is not launched yet. That's why we added a test CSPR.name for the Faucet account to allow developers to implement and test their CSPR.name integration before the launch.

Direct CSPR.name to account hash resolution can be done using the [Get CSPR.name resolution API](https://docs.cspr.cloud/1.4.x/rest-api/cspr-name-resolution/get-cspr-name-resolution) and is recommended for the situations when you receive the name outside CSPR.cloud and want to resolve it to the corresponding account hash:

```bash
curl -X 'GET' \
  'https://api.testnet.cspr.cloud/cspr-name-resolutions/faucet.cspr' \
  -H 'accept: application/json' \
  -H 'authorization: 55f79117-fc4d-4d60-9956-65423f39a06a'
```

```json
{
  "data": {
    "name_token_id": "0000000000000000000000000000000000000000000000000000000000000000",
    "name": "faucet.cspr",
    "resolved_hash": "b383c7cc23d18bc1b42406a1b2d29fc8dba86425197b6f553d7fd61375b5e446",
    "expires_at": "2124-08-27T12:00:00Z"
  }
}
```

In situations, when you want to resolve account hashes to the corresponding CSPR.name names, in most of the cases it's possible to do by requesting CSPR.name as [optional property](https://docs.cspr.cloud/1.4.x/documentation/overview/optional-properties) in the `includes` query parameter:

```bash
curl -X 'GET' \
  'https://api.testnet.cspr.cloud/deploys/872394dcb8ac58b61f543e6fa0e3425b1db6b83a03d9d46cbf55c9d4b736624f?includes=caller_cspr_name' \
  -H 'accept: application/json' \
  -H 'authorization: 55f79117-fc4d-4d60-9956-65423f39a06a'
```

```json
{
  "data": {
    "args": {
      "amount": {
        "cl_type": "U512",
        "parsed": "1000000000000"
      },
      "target": {
        "cl_type": {
          "ByteArray": 32
        },
        "parsed": "3234c6a8e17a19976300d18d6dcc444839ff981c5bfcd0d8724e3a0c018f61f3"
      }
    },
    "block_hash": "b8e7c74faed73e54be402a5f575a6cd8adf7382ed58bdb0ed48271464a122415",
    "block_height": 3618748,
    "caller_cspr_name": "faucet.cspr",
    "caller_public_key": "018afa98ca4be12d613617f7339a2d576950a2f9a92102ca4d6508ee31b54d2c02",
    "contract_hash": null,
    "contract_package_hash": null,
    "cost": "2976291766",
    "deploy_hash": "872394dcb8ac58b61f543e6fa0e3425b1db6b83a03d9d46cbf55c9d4b736624f",
    "entry_point_id": null,
    "error_message": null,
    "execution_type_id": 1,
    "payment_amount": "4000000000",
    "status": "processed",
    "timestamp": "2024-08-26T14:34:56Z"
  }
}
```

If you want to find the primary CSPR.name for an account, you can include it in the [Get account API](https://docs.cspr.cloud/1.4.x/rest-api/account/get-account):

```bash
curl -X 'GET' \
  'https://api.testnet.cspr.cloud/accounts/018afa98ca4be12d613617f7339a2d576950a2f9a92102ca4d6508ee31b54d2c02?includes=cspr_name' \
  -H 'accept: application/json' \
  -H 'authorization: 55f79117-fc4d-4d60-9956-65423f39a06a'
```

```json
{
  "data": {
    "account_hash": "b383c7cc23d18bc1b42406a1b2d29fc8dba86425197b6f553d7fd61375b5e446",
    "balance": 9516302858997050000,
    "cspr_name": "faucet.cspr",
    "deployment_threshold": 1,
    "key_management_threshold": 1,
    "main_purse_uref": "uref-b06a1ab0cfb52b5d4f9a08b68a5dbe78e999de0b0484c03e64f5c03897cf637b-007",
    "public_key": "018afa98ca4be12d613617f7339a2d576950a2f9a92102ca4d6508ee31b54d2c02"
  }
}
```
