> For the complete documentation index, see [llms.txt](/llms.txt).

# Integrate Embedded Wallets with the ImmutableX Blockchain

While using the Embedded Wallets Web SDK (formerly Web3Auth), you get an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider, similar to the MetaMask provider. This provider can be used with libraries like [web3.js](https://docs.web3js.org/), [ethers.js](https://docs.ethers.io/v5/getting-started/) etc. to make [ImmutableX](https://www.avalabs.org) blockchain calls. However, since this chain is not fully EVM-compatible, there are a few extra setup requirements. We've highlighted a few methods here to get you started.

note

This reference is for the `Web`, however, you can use ImmutableX on other Mobile and Gaming Platforms as well. Please follow our reference for [EVM Blockchains](/embedded-wallets/connect-blockchain/evm/), and similarly use ImmutableX libraries that support the platforms to use the private key and make blockchain calls accordingly.

## Installation[​](#installation "Direct link to Installation")

- npm
- Yarn
- pnpm
- Bun

```
npm install --save @imtbl/core-sdk

```

```
yarn add @imtbl/core-sdk

```

```
pnpm add @imtbl/core-sdk

```

```
bun add @imtbl/core-sdk

```

## Initializing provider[​](#initializing-provider "Direct link to Initializing provider")

### Getting the `chainConfig`[​](#getting-the-chainconfig "Direct link to getting-the-chainconfig")

- Mainnet
- Testnet

- Chain Namespace: EIP155
- Chain ID: 0x1
- Public RPC URL: `https://rpc.ethereum.org` (Avoid using public rpcTarget in production)
- Display Name: ImmutableX Mainnet
- Block Explorer Link: `https://explorer.immutable.com`
- Ticker: IMX
- Ticker Name: ImmutableX

- Chain Namespace: EIP155
- Chain ID: 0xaa36a7
- Public RPC URL: `https://ethereum-sepolia.publicnode.com` (Avoid using public rpcTarget in production)
- Display Name: ImmutableX Testnet
- Block Explorer Link: `https://explorer.testnet.immutable.com`
- Ticker: IMX
- Ticker Name: ImmutableX

## Creating Layer 1 and Layer 2 signers[​](#creating-layer-1-and-layer-2-signers "Direct link to Creating Layer 1 and Layer 2 signers")

Once a user logs in, the Embedded Wallets SDK returns a provider. ImmutableX is a layer 2 solution for Ethereum, so we'll create an ETH signer using the provider (via ethers). Then we use the helper function `createStarkSigner` from `@imtbl/core-sdk` to create a Stark signer from the private key.

```
import { IProvider } from '@web3auth/base'
import { ImmutableX, Config, createStarkSigner } from '@imtbl/core-sdk'
import { ethers } from 'ethers'

/*
  Use code from the above Initializing Provider here
*/

const ethersProvider = new ethers.providers.Web3Provider(web3authProvider)
const ethSigner = ethersProvider.getSigner()

// Get user's Ethereum public address
const address = await ethSigner.getAddress()

// Get user's Starkex public address

const starkKey = await web3authProvider.request({ method: 'private_key' })
const starkSigner = createStarkSigner(starkKey)

```

After creating the signers, we need to register these signers with the ImmutableX SDK. We can do this by calling the `registerOffchain` method.

```
const config = Config.SANDBOX // Or Config.PRODUCTION or Config.ROPSTEN
const client = new ImmutableX(config)

// We use the signers we created in the above step

const walletConnection = { ethSigner, starkSigner }
const response = await client.registerOffchain(walletConnection)

```

## Get balance[​](#get-balance "Direct link to Get balance")

We can get the Layer 1 ( Ethereum ) balance using the below code snippet.

```
const ethersProvider = new ethers.providers.Web3Provider(web3authProvider)
const signer = ethersProvider.getSigner()

// Get user's Ethereum public address
const address = await signer.getAddress()

// Get user's balance in ether
const balance = ethers.utils.formatEther(
  await ethersProvider.getBalance(address) // Balance is in wei
)

```

## Send funds from Layer 1 to Layer 2[​](#send-funds-from-layer-1-to-layer-2 "Direct link to Send funds from Layer 1 to Layer 2")

```
const ethersProvider = new ethers.providers.Web3Provider(web3authProvider)
const ethSigner = ethersProvider.getSigner()
const depositResponse = await client.deposit(ethSigner, {
  type: 'ETH',
  amount: '10000000000000', // Amount in wei
})

```
