Skip to main content
Version: v2.x.x

Migrating to V2

lit-js-sdk is now considered deprecated and will only receive security updates. It is strongly recommended to migrate to the new Lit JS SDK V2 for continued support and new features.

The Lit JS SDK V2 has been entirely revamped from the earlier lit-js-sdk and completely rewritten in TypeScript. This latest V2 SDK is much more modular and easier to use, and has a noticeably smaller bundle size.

Installing the V2 SDK

note

You should use at least Node v16.16.0 because of the need for the webcrypto library.

Get started with Lit JS SDK V2 by installing the package best suited for your environment.

Browser & Node environments:

npm install @lit-protocol/lit-node-client@serrano

Node environment:

npm install @lit-protocol/lit-node-client-nodejs

If you already have lit-js-sdk in your app, all you need to do is remove the old package and then update any import statement to reference the new SDK like so:

import * as LitJsSdk from '@lit-protocol/lit-node-client@serrano';

If you are using TypeScript, be sure to install the @lit-protocol/types package. Check out the list of available packages here.

Notable Changes

Lit JS SDK V2 includes some breaking changes from the latest version of the old lit-js-sdk.

Updating Imports

Some methods have been moved to separate packages and must be accessed from those packages. Below are lists of methods underneath their respective packages.

@lit-protocol/crypto

  • decryptWithSymmetricKey
  • encryptWithSymmetricKey
  • importSymmetricKey
  • generateSymmetricKey

@lit-protocol/misc-browser

  • fileToDataUrl
  • injectViewerIFrame
  • downloadFile

@lit-protocol/access-control-conditions

  • hashUnifiedAccessControlConditions

@lit-protocol/misc

  • getVarType
  • checkType
  • convertLitActionsParams
  • decimalPlaces

Constants have been moved to @lit-protocol/constants, which include:

  • LIT_CHAINS
  • LIT_SVM_CHAINS
  • LIT_COSMOS_CHAINS
  • ALL_LIT_CHAINS

The following types are now declared in @lit-protocol/types:

  • LITChain
  • LITEVMChain
  • LITSVMChain
  • LITCosmosChain
  • CallRequest

Changed Methods

signAndSaveAuthMessage

VersionCode
V1

import * as LitJsSdk from "lit-js-sdk";
const authSig = await LitJsSdk.signAndSaveAuthMessage({..});
V2

import { ethConnect } from "@lit-protocol/auth-browser";,
const authSig = await ethConnect.signAndSaveAuthMessage({..});
note

For V2: You can also import cosmosConnect and solConnect for Cosmos and Solana respectively.

disconnectWeb3

VersionCode
V1

import * as LitJsSdk from "lit-js-sdk";
LitJsSdk.disconnectWeb3();
V2

import { ethConnect } from "@lit-protocol/auth-browser";,
ethConnect.disconnectWeb3();

executeJs

authSig is a required parameter.

getSignedToken

This method accepts iat and exp as optional parameters.

saveEncryptionKey

The optional permanent parameters are now type number.

saveSigningCondition

The optional permanent parameters are now type number.

signSessionKey

The parameter chain is now chainId and type number.


Changed Types

AccessControlCondition is now either AccsRegularParams or AccsDefaultParams and referenced in AccessControlConditions.


EVMContractCondition is now AccsEVMParams and referenced in EvmContractConditions.


SolRpcCondition is now AccsSOLV2Params , which now includes more properties like pdaKey, pdaInterface, and pdaParams. AccsSOLV2Params is referenced in SolRpcConditions.


CosmosCondition is now ConditionItem.


ResourceId is now JsonSigningResourceId.


Deprecated Methods

These methods are no longer supported:

  • signPKPTransaction
  • sendPKPTransaction
  • findLITs
  • sendLIT
  • createHtmlLIT
  • mintLIT
  • unlockLitWithKey
  • toggleLock
  • encryptWithPubKey
  • decryptWithPrivKey
  • lookupNameServiceAddress
  • metadataForFile
  • configure

Changelog

Changes to the Lit JS SDK V2 will be tracked in the changelog.