Skip to content

Import Wallet

After you have created a wallet, you can import it afterward by providing a configuration. You can import wallets even if they are not created by Kriptonio SDK.

Exported Wallets

If you have exported a wallet via Kriptonio SDK, you can import it like this:

import { ChainId, KriptonioSdk } from '@kriptonio/sdk';
 
const sdk = new KriptonioSdk({
  accessToken: 'your-access-token',
});
 
const wallet = await sdk.wallet.generate({
  chainId: ChainId.BaseSepolia,
  type: 'kernel',
});
 
const exported = wallet.export();

const imported = await sdk.wallet.from(exported, {
  chainId: ChainId.Polygon,
});

Smart Wallet

To import a smart wallet, you can use the following code:

import { ChainId, KriptonioSdk } from '@kriptonio/sdk';
 
const sdk = new KriptonioSdk({
  accessToken: 'your-access-token',
});
 

const wallet = await sdk.wallet.from(
  {
    kernel: {
      privateKey: '0x...',
    },
  },
  {
    chainId: ChainId.Polygon,
  },
);

Classic Wallet

To import a classic EOA (Externally Owned Account) wallet, you can use the following code:

import { ChainId, KriptonioSdk } from '@kriptonio/sdk';
 
const sdk = new KriptonioSdk({
  accessToken: 'your-access-token',
});
 

const wallet = await sdk.wallet.from(
  {
    eoa: {
      privateKey: '0x...',
    },
  },
  {
    chainId: ChainId.Polygon,
  },
);

Anonymous Import

If you don't want to authenticate with Kriptonio SDK, you can still import a wallet by providing a configuration:

import { WalletFactory } from '@kriptonio/sdk';
 

const wallet = await WalletFactory.from({
  kernel: {
    privateKey: '0x',
    rpcUrl: 'https://...',
    paymasterUrl: 'https://',
  },
});