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

By default,XpansionChain's registerUser 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?

  • 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:

📝GUIDES

  • Core SDK

  • Link SDK

Core SDK

1. Initialize the Core SDK

In order to use the Core SDK, you need to initialize it.

2. Generate signers

Registering a user requires the user's signature, so your application will need to create signers. See the guide on how to generate signers.

3. Register the user

  • Typescript Core SDK

📚SDK REFERENCE

  • registerOffchain

const walletConnection = { ethSigner, starkSigner };

client.registerOffchain(walletConnection);
  • Kotlin (JVM) Core SDK

📚SDK REFERENCE

  • registerOffchain

XpansionChainCore.registerOffchain(signer, starkSigner)

  • Swift Core SDK

📚SDK REFERENCE

  • registerOffchain

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

  • Golang Core SDK

📚SDK REFERENCE

  • RegisterOffchain

See this example.

Last updated