Generating L2 Key Pairs

This page helps you generate L2 key pairs either through the tanX website or with a code snippet.

To obtain the L2 Key Pair, you can proceed with either of the following methods:

  1. Once the wallet is connected, obtain the Key Pair from the official tanX website’s Account Settings Tab. Please refer to the image below for further guidance: Navigate to Settings -> tanX key -> Show Keys and sign the request to obtain the keys. Copy these keys and securely store them.

  1. Generate the L2 key pair using the tanX Node.js SDK:

import { generateKeyPairFromEthPrivateKey } from '@tanx-libs/tanx-connector'

const keypair = generateKeyPairFromEthPrivateKey(ethPrivateKey, 'testnet') // default is mainnet
const stark_public_key = keypair.getPublic().getX().toString('hex') 
const stark_private_key = keypair.getPrivate().toString('hex')

This code snippet demonstrates how to generate L2 key pairs programmatically using the tanX Node.js SDK.

Last updated