> For the complete documentation index, see [llms.txt](https://xpansionchain-1.gitbook.io/xpansionchain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xpansionchain-1.gitbook.io/xpansionchain/guides/basic-guides/register-users.md).

# Register users

## Register users

User registration consists of two parts:

1. Generating an XpansionChain L2 user account for an Ethereum L1 account
2. Registering the L1 <-> L2 wallet pair

This enables the following:

* A user with an Ethereum L1 account now has an associated L2 account on XpansionChain
* L1 users can deposit L1 assets to their L2 account
* An L2 user can transact on XpansionChain (create orders, trade assets, transfer assets, etc.)
* An L2 user can withdraw their assets on L2 to their L1 account

#### Off-chain, then on-chain registration[​](https://docs.x.immutable.com/docs/x/how-to-register-users#off-chain-then-on-chain-registration) <a href="#off-chain-then-on-chain-registration" id="off-chain-then-on-chain-registration"></a>

By default,XpansionChain's <mark style="color:blue;">registerUser</mark> endpoint first registers a user **off-chain**. This means that the L1-L2 wallet pair is recorded in an XpansionChain database. All transactions that the user performs on L2 are recorded against this registered L2 user, however, L1 is not yet aware of the wallet mapping.

Then, when the users performs a transaction that requires an update of the state of the corresponding L1 wallet (ie. withdrawing an NFT from the L2 wallet to the L1 wallet), the user is registered **on-chain**, which means recording the L1-L2 wallet pair on Ethereum (L1).

#### What's going on under the hood?[​](https://docs.x.immutable.com/docs/x/how-to-register-users#whats-going-on-under-the-hood) <a href="#whats-going-on-under-the-hood" id="whats-going-on-under-the-hood"></a>

* A deterministic calculation according to EIP-2645 which uses the user's Ethereum key to sign a static string.
* This signature is used as a cryptographic seed with generic path parameters defined by the proposal's derivation path for hierarchical keys: `m / purpose' / layer' / application' / eth_address_1' / eth_address_2' / index` (This is the step that binds the L2 key with the L1 key)
* The generated private key is then passed through an efficient grinding method to enforce distribution within STARK's elliptic curve domain. The generated key pair is what you'll be using on a day-to-day basis to interact with any XpansionChain functionality.

This is a high-level overview of the user registration process:&#x20;

<figure><img src="https://3017072639-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7a6afyDwSEkvWtt1UhmH%2Fuploads%2FeqxwPfYpAirPtGkbXuWO%2F%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230804182520.png?alt=media&amp;token=b795d5e9-9b21-4ab4-9aa8-52f9bba85045" alt=""><figcaption></figcaption></figure>

📝GUIDES

* <mark style="color:blue;">Core SDK</mark>
* <mark style="color:blue;">Link SDK</mark>

### Core SDK[​](https://docs.x.immutable.com/docs/x/how-to-register-users#core-sdk) <a href="#core-sdk" id="core-sdk"></a>

#### 1. Initialize the Core SDK[​](https://docs.x.immutable.com/docs/x/how-to-register-users#1-initialize-the-core-sdk) <a href="#id-1-initialize-the-core-sdk" id="id-1-initialize-the-core-sdk"></a>

In order to use the Core SDK, you need to <mark style="color:blue;">initialize it</mark>.

#### 2. Generate signers[​](https://docs.x.immutable.com/docs/x/how-to-register-users#2-generate-signers) <a href="#id-2-generate-signers" id="id-2-generate-signers"></a>

Registering a user requires the user's signature, so your application will need to create signers. See the guide on <mark style="color:blue;">how to generate signers</mark>.

#### 3. Register the user[​](https://docs.x.immutable.com/docs/x/how-to-register-users#3-register-the-user) <a href="#id-3-register-the-user" id="id-3-register-the-user"></a>

* Typescript Core SDK

📚SDK REFERENCE

* <mark style="color:blue;">registerOffchain</mark>

```
const walletConnection = { ethSigner, starkSigner };

client.registerOffchain(walletConnection);
```

* Kotlin (JVM) Core SDK

📚SDK REFERENCE

* <mark style="color:blue;">registerOffchain</mark>

```
XpansionChainCore.registerOffchain(signer, starkSigner)
```

* Swift Core SDK

📚SDK REFERENCE

* <mark style="color:blue;">registerOffchain</mark>

```
UsersApi.registerUser(ethSignature, etherKey, starkKey, starkSignature)
```

* Golang Core SDK

📚SDK REFERENCE

* <mark style="color:blue;">RegisterOffchain</mark>

See <mark style="color:blue;">this example.</mark>
