> For the complete documentation index, see [llms.txt](https://bitfinity-2.gitbook.io/btcx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bitfinity-2.gitbook.io/btcx/bitfinity-btc-domains.md).

# Bitfinity BTC Domains

### Introduction

Bitfinity Domains are a namespace for Bitcoin Layer2 domains, allowing for the following extensions:

```
.bft .bitfinity .btc .btcx
```

A single domain, for instance *<mark style="color:yellow;">**hello.btc**</mark>*  will resolve to a JSON object with several fields:

* A P2WSH address
* A Taproot (P2TR) address
* An EVM address&#x20;
* An IC principal address
* Metadata to store vanity URLs for instance

These fields are all optional and enable multiple address types to be associated with your domain, so that you can use the same address for Bitcoin as for the EVM. A user may have a P2TR address as well as a P2WSH address.&#x20;

```json
{
  "name": "domain_name_as_string",
  "bitcoin_p2tr_address": "bitcoin_p2tr_address_as_string",
  "bitcoin_p2wpkh_hash": "bitcoin_p2wpkh_hash_as_string",
  "ethereum_address": "ethereum_address_as_hex_string",
  "principal": "principal_as_string",
  "metadata": {
    "key1": "value1",
    "key2": "value2"
    // ... other key-value pairs
  },
  "expire_at": timestamp_as_number
}
```

The Rust struct underpinning the data ius given to show which fields are optional.

```rust
pub struct DomainInfo {
    pub name: String,
    pub principal: Principal,
    pub bitcoin_p2tr_address: Option<String>,
    pub bitcoin_p2wpkh_hash: Option<String>,
    pub ethereum_address: Option<String>,
    pub expire_at: u64,
    pub metadata: HashMap<String, String>,
}
```

Bitfinity domains are hosted on the Internet Computer, a decentralised web-server. In future, there will be an option to migrate your domain to the Bitcoin base-layer for an additional fee.

### Installation

You can download the javascript sdk from here:

```bash
npm install @bitfinity-network/bitdns
```

### Resolving Domains

This JavaScript code snippet demonstrates how to use the Bitfinity Network's DNS SDK to resolve a domain name and retrieve its associated information.\
\
The  SDK provides a resolve function, which is used to retrieve the records for a specific domain.\
\
The resolve function is asynchronous and returns a Promise that resolves to the domain information if the domain exists, or null if the domain does not exist. <br>

<pre class="language-javascript"><code class="lang-javascript">import { resolve, available } from '@bitfinity-network/bitdns';

// Getting the records for the domain
const domainInfo = await resolve('testing.bft');

if (domainInfo) {
  console.log('Domain found');
  console.log(`Registered principal: ${domainInfo.principal.toText()}`);
} else {
  console.log('Domain NOT found');
}

<strong>
</strong></code></pre>

### Availability

This JavaScript code snippet uses the Bitfinity Network's DNS SDK to check the availability of a domain name across multiple suffixes.

This object returned contains key-value pairs where the keys are domain suffixes and the values are booleans indicating whether 'mycooldomain' is available with that suffix.

```javascript
import { available } from '@bitfinity-network/bitdns';

//checking if the domain is available

const namesAvailable = await available('mycooldomain');

for (let [suffix, canRegister] of Object.entries(namesAvailable)) {
  if (canRegister) {
    console.log(`mycooldomain.${suffix} is available`);
  } else {
    console.log(`mycooldomain.${suffix} is NOT available`);
  }
} 
```

### Registration

Registration is not available from the CLI, please visit:\
\
<https://docs.google.com/forms/d/e/1FAIpQLSdYQpWCovoJ0x1mQkBHyVyEL8FAKUWtziCMwlHcYy7FJujcjw/viewform>
