# Registry

The registry is a singleton contract that serves as the entry point for all tokenbound account address queries.&#x20;

It allows for the deterministic calculation and deployment of Tokenbound Account addresses.

The full contract code of the Registry can be found [**here**](https://github.com/horuslabsio/TBA/blob/v3/src/registry/registry.cairo)**.**

## Functions

### `create_account`

```rust
fn create_account(
    ref self: ContractState,
    implementation_hash: felt252,
    token_contract: ContractAddress,
    token_id: u256,
    salt: felt252,
    chain_id: felt252
) -> ContractAddress
```

This function deploys a new Tokenbound Account for an NFT. It requires that the caller is the owner of the specific NFT.

#### Parameters

| Name                  | Type              | Description                                                                                       |
| --------------------- | ----------------- | ------------------------------------------------------------------------------------------------- |
| `implementation_hash` | `felt252`         | The class hash of the reference account                                                           |
| `token_contract`      | `ContractAddress` | The contract address of the NFT                                                                   |
| `token_id`            | `u256`            | The NFT token ID                                                                                  |
| `salt`                | `felt252`         | A random value that enforces the uniqueness of the deterministic address calculation for the TBA. |
| `chain_id`            | `felt252`         | The network/chain ID                                                                              |

**Returns:**&#x20;

* `account_address (ContractAddress)`: The deployed Tokenbound Account address for the provided NFT.

### `get_account`

```rust
fn get_account(
    self: @ContractState,
    implementation_hash: felt252,
    token_contract: ContractAddress,
    token_id: u256,
    salt: felt252,
    chain_id: felt252
) -> ContractAddress
```

This function calculates the address of a Tokenbound Account without deploying it. The account address is calculated deterministically using the provided contract address, token ID, and other parameters, meaning that the address will be the same each time for a given set of inputs.

#### Parameters

| Name                  | Type              | Description                                                                                      |
| --------------------- | ----------------- | ------------------------------------------------------------------------------------------------ |
| `implementation_hash` | `felt252`         | The class hash of AccountV3 (implementation contract)                                            |
| `token_contract`      | `ContractAddress` | The contract address of the NFT                                                                  |
| `token_id`            | `u256`            | The NFT token ID                                                                                 |
| `salt`                | `felt252`         | A random value that enforces the uniqueness of the deterministic address calculation for the TBA |
| `chain_id`            | `felt252`         | The Network/chain ID                                                                             |

**Returns:**&#x20;

* `account_address (ContractAddress)`: The calculated Tokenbound Account address for the provided NFT and parameters.
