Welcome

Welcome to the LIT JS SDK API documentation. To understand how these functions fit together, please view the documentation for this SDK, located at https://developer.litprotocol.com/docs/SDK/intro

LitNodeClient

A LIT node client. Connects directly to the LIT nodes to store and retrieve encryption keys and signing requests. Only holders of an NFT that corresponds with a LIT may store and retrieve the keys.

new LitNodeClient(config: Object)
Parameters
config (Object)
Name Description
config.alertWhenUnauthorized boolean (default true) Whether or not to show a JS alert() when a user tries to unlock a LIT but is unauthorized. An exception will also be thrown regardless of this option.
config.minNodeCount number (default 6) The minimum number of nodes that must be connected for the LitNodeClient to be ready to use.
config.debug boolean (default true) Whether or not to show debug messages.
Instance Members
getSignedChainDataToken(params)
getSignedToken(params)
saveSigningCondition(params)
getEncryptionKey(params)
saveEncryptionKey(params)
connect()

Static Content - Encryption and decryption utilities

encryptString

Encrypt a string. This is used to encrypt any string that is to be locked via the Lit Protocol.

encryptString(str: string): Promise<Object>
Parameters
str (string) The string to encrypt
Returns
Promise<Object>: A promise containing the encryptedString as a Blob and the symmetricKey used to encrypt it, as a Uint8Array.

decryptString

Decrypt a string that was encrypted with the encryptString function.

decryptString(encryptedStringBlob: (Blob | File), symmKey: Uint8Array): Promise<string>
Parameters
encryptedStringBlob ((Blob | File)) The encrypted string as a Blob
symmKey (Uint8Array) The symmetric key used that will be used to decrypt this.
Returns
Promise<string>: A promise containing the decrypted string

encryptFile

Encrypt a file without doing any zipping or packing. This is useful for large files. A 1gb file can be encrypted in only 2 seconds, for example. A new random symmetric key will be created and returned along with the encrypted file.

encryptFile(params: Object): Promise<Object>
Parameters
params (Object)
Name Description
params.file (Blob | File) The file you wish to encrypt
Returns
Promise<Object>: A promise containing an object with keys encryptedFile and symmetricKey. encryptedFile is a Blob, and symmetricKey is a Uint8Array that can be used to decrypt the file.

decryptFile

Decrypt a file that was encrypted with the encryptFile function, without doing any unzipping or unpacking. This is useful for large files. A 1gb file can be decrypted in only 1 second, for example.

decryptFile(params: Object): Promise<ArrayBuffer>
Parameters
params (Object)
Name Description
params.file (Blob | File) The file you wish to decrypt
params.symmetricKey Uint8Array The symmetric key used that will be used to decrypt this.
Returns
Promise<ArrayBuffer>: A promise containing the decrypted file. The file is an ArrayBuffer.

zipAndEncryptString

Zip and encrypt a string. This is used to encrypt any string that is to be locked via the Lit Protocol.

zipAndEncryptString(string: string): Promise<Object>
Parameters
string (string) The string to zip and encrypt
Returns
Promise<Object>: A promise containing the encryptedZip as a Blob and the symmetricKey used to encrypt it, as a Uint8Array. The encrypted zip will contain a single file called "string.txt"

zipAndEncryptFiles

Zip and encrypt multiple files.

zipAndEncryptFiles(files: Array<File>): Promise<Object>
Parameters
files (Array<File>) An array of the files you wish to zip and encrypt
Returns
Promise<Object>: A promise containing the encryptedZip as a Blob and the symmetricKey used to encrypt it, as a Uint8Array. The encrypted zip will contain a folder "encryptedAssets" and all of the files will be inside it.

encryptFileAndZipWithMetadata

Encrypt a single file, save the key to the Lit network, and then zip it up with the metadata.

encryptFileAndZipWithMetadata(params: Object): Promise<Object>
Parameters
params (Object)
Name Description
params.authSig Object The authSig of the user. Returned via the checkAndSignAuthMessage function
params.accessControlConditions Array<AccessControlCondition> The access control conditions that the user must meet to obtain this signed token. This could be posession of an NFT, for example. You must pass either accessControlConditions or evmContractConditions or solRpcConditions or unifiedAccessControlConditions.
params.evmContractConditions Array<EVMContractCondition> EVM Smart Contract access control conditions that the user must meet to obtain this signed token. This could be posession of an NFT, for example. This is different than accessControlConditions because accessControlConditions only supports a limited number of contract calls. evmContractConditions supports any contract call. You must pass either accessControlConditions or evmContractConditions or solRpcConditions or unifiedAccessControlConditions.
params.solRpcConditions Array<SolRpcCondition> Solana RPC call conditions that the user must meet to obtain this signed token. This could be posession of an NFT, for example.
params.unifiedAccessControlConditions Array<(AccessControlCondition | EVMContractCondition | SolRpcCondition)> An array of unified access control conditions. You may use AccessControlCondition, EVMContractCondition, or SolRpcCondition objects in this array, but make sure you add a conditionType for each one. You must pass either accessControlConditions or evmContractConditions or solRpcConditions or unifiedAccessControlConditions.
params.chain string The chain name of the chain that this contract is deployed on. See LIT_CHAINS for currently supported chains.
params.file File The file you wish to encrypt
params.litNodeClient LitNodeClient An instance of LitNodeClient that is already connected
params.readme string An optional readme text that will be inserted into readme.txt in the final zip file. This is useful in case someone comes across this zip file and wants to know how to decrypt it. This file could contain instructions and a URL to use to decrypt the file.
Returns
Promise<Object>: A promise containing an object with 3 keys: zipBlob, encryptedSymmetricKey, and symmetricKey. zipBlob is a zip file that contains an encrypted file and the metadata needed to decrypt it via the Lit network. encryptedSymmetricKey is the symmetric key needed to decrypt the content, encrypted with the Lit network public key. You may wish to store encryptedSymmetricKey in your own database to support quicker re-encryption operations when adding additional access control conditions in the future, but this is entirely optional, and this key is already stored inside the zipBlob. symmetricKey is the raw symmetric key used to encrypt the files. DO NOT STORE IT. It is provided in case you wish to create additional "OR" access control conditions for the same file.

decryptZipFileWithMetadata

Given a zip file with metadata inside it, unzip, load the metadata, and return the decrypted file and the metadata. This zip file would have been created with the encryptFileAndZipWithMetadata function.

decryptZipFileWithMetadata(params: Object): Promise<Object>
Parameters
params (Object)
Name Description
params.authSig Object The authSig of the user. Returned via the checkAndSignAuthMessage function
params.file (Blob | File) The zip file blob with metadata inside it and the encrypted asset
params.litNodeClient LitNodeClient An instance of LitNodeClient that is already connected
params.additionalAccessControlConditions any
Returns
Promise<Object>: A promise containing an object that contains decryptedFile and metadata properties. The decryptedFile is an ArrayBuffer that is ready to use, and metadata is an object that contains all the properties of the file like it's name and size and type.

encryptZip

Encrypt a zip file created with JSZip using a new random symmetric key via WebCrypto.

encryptZip(zip: JSZip): Promise<Object>
Parameters
zip (JSZip) The JSZip instance to encrypt
Returns
Promise<Object>: A promise containing the encryptedZip as a Blob and the symmetricKey used to encrypt it, as a Uint8Array string.

decryptZip

Decrypt and unzip a zip that was created using encryptZip, zipAndEncryptString, or zipAndEncryptFiles.

decryptZip(encryptedZipBlob: (Blob | File), symmKey: Uint8Array): Promise<Object>
Parameters
encryptedZipBlob ((Blob | File)) The encrypted zip as a Blob
symmKey (Uint8Array) The symmetric key used that will be used to decrypt this zip.
Returns
Promise<Object>: A promise containing a JSZip object indexed by the filenames of the zipped files. For example, if you have a file called "meow.jpg" in the root of your zip, you could get it from the JSZip object by doing this: const imageBlob = await decryptedZip['meow.jpg'].async('blob')

decryptWithSymmetricKey

Decrypt an encrypted blob with a symmetric key. Uses AES-CBC via SubtleCrypto

decryptWithSymmetricKey(encryptedBlob: Blob, symmKey: Object): Blob
Parameters
encryptedBlob (Blob) The encrypted blob that should be decrypted
symmKey (Object) The symmetric key
Returns
Blob: The decrypted blob

encryptWithSymmetricKey

Encrypt a blob with a symmetric key

encryptWithSymmetricKey(symmKey: Object, data: Blob): Blob
Parameters
symmKey (Object) The symmetric key
data (Blob) The blob to encrypt
Returns
Blob: The encrypted blob

Dynamic Content - Loading content from a server

verifyJwt

Verify a JWT from the LIT network. Use this for auth on your server. For some background, users can define resources (URLs) for authorization via on-chain conditions using the saveSigningCondition function. Other users can then request a signed JWT proving that their ETH account meets those on-chain conditions using the getSignedToken function. Then, servers can verify that JWT using this function. A successful verification proves that the user meets the on-chain conditions defined in the saveSigningCondition step. For example, the on-chain condition could be posession of a specific NFT.

verifyJwt(params: Object): Object
Parameters
params (Object)
Name Description
params.jwt string A JWT signed by the LIT network using the BLS12-381 algorithm
Returns
Object: An object with 4 keys: "verified": A boolean that represents whether or not the token verifies successfully. A true result indicates that the token was successfully verified. "header": the JWT header. "payload": the JWT payload which includes the resource being authorized, etc. "signature": A uint8array that represents the raw signature of the JWT.

Authentication Signature Utilities

checkAndSignAuthMessage

Check for an existing cryptographic authentication signature and create one of it does not exist. This is used to prove ownership of a given crypto wallet address to the Lit nodes. The result is stored in LocalStorage so the user doesn't have to sign every time they perform an operation.

checkAndSignAuthMessage(params: Object): AuthSig
Parameters
params (Object)
Name Description
params.chain string The chain you want to use. Find the supported list of chains here: https://developer.litprotocol.com/docs/supportedChains
params.resources Array<string> Optional and only used with EVM chains. A list of resources to be passed to Sign In with Ethereum. These resources will be part of the Sign in with Ethereum signed message presented to the user.
params.switchChain Array<boolean> (default true) Optional and only used with EVM chains right now. Set to true by default. Whether or not to ask Metamask or the user's wallet to switch chains before signing. This may be desired if you're going to have the user send a txn on that chain. On the other hand, if all you care about is the user's wallet signature, then you probably don't want to make them switch chains for no reason. Pass false here to disable this chain switching behavior.
Returns
AuthSig: The AuthSig created or retrieved

signAndSaveAuthMessage

Sign the auth message with the user's wallet, and store it in localStorage. Called by checkAndSignAuthMessage if the user does not have a signature stored.

signAndSaveAuthMessage(params: Object): AuthSig
Parameters
params (Object)
Name Description
params.web3 Web3Provider An ethers.js Web3Provider instance
params.account string The account to sign the message with
params.chainId any
params.resources any
Returns
AuthSig: The AuthSig created or retrieved

disconnectWeb3

Delete any saved AuthSigs from local storage. Takes no params and returns nothing. This will also clear out the WalletConnect cache in local storage. We often run this function as a result of the user pressing a "Logout" button.

disconnectWeb3()

Conversion Utilities

blobToBase64String

Convert a Blob to a base64urlpad string. Note: This function returns a promise.

blobToBase64String(blob: (Blob | File)): Promise<String>
Parameters
blob ((Blob | File)) The Blob or File to turn into a base64 string
Returns
Promise<String>: A promise that resolves to the base64 string

base64StringToBlob

Convert a base64urlpad string to a Blob. Note: This function DOES NOT return a promise

base64StringToBlob(base64String: String): Blob
Parameters
base64String (String) The base64 string that to turn into a Blob
Returns
Blob: A blob that contains the decoded base64 data

uint8arrayToString

Convert a Uint8Array to a string. Supports various encodings. This is a re-export of https://www.npmjs.com/package/uint8arrays and you can find the list of supported encodings here https://github.com/multiformats/multibase/blob/master/multibase.csv

uint8arrayToString(uint8array: Uint8Array, encoding: String): String
Parameters
uint8array (Uint8Array) The Uint8Array to convert to a string
encoding (String) The encoding to use when converting the Uint8Array to a string.
Returns
String: The string representation of the Uint8Array

uint8arrayFromString

Convert a string to a Uint8Array. Supports various encodings. This is a re-export of https://www.npmjs.com/package/uint8arrays and you can find the list of supported encodings here https://github.com/multiformats/multibase/blob/master/multibase.csv

uint8arrayFromString(str: String, encoding: String): String
Parameters
str (String) The string to convert to a Uint8Array
encoding (String) The encoding to use when converting the string to a Uint8Array.
Returns
String: The Uint8Array representation of the data from the string

fileToDataUrl

Convert a file to a data URL, which could then be embedded in a LIT. A data URL is a string representation of a file.

fileToDataUrl(file: File): string
Parameters
file (File) The file to turn into a data url
Returns
string: The data URL. This is a string representation that can be used anywhere the original file would be used.

Other Utilities

humanizeAccessControlConditions

The human readable name for an access control condition

humanizeAccessControlConditions(params: Object): Promise<string>
Parameters
params (Object)
Name Description
params.accessControlConditions Array The array of access control conditions that you want to humanize
params.evmContractConditions Array The array of evm contract conditions that you want to humanize
params.solRpcConditions Array The array of Solana RPC conditions that you want to humanize
params.unifiedAccessControlConditions Array The array of unified access control conditions that you want to humanize
params.tokenList any
params.myWalletAddress any
Returns
Promise<string>: A promise containing a human readable description of the access control conditions

hashUnifiedAccessControlConditions

Hash the unified access control conditions using SHA-256 in a deterministic way.

hashUnifiedAccessControlConditions(unifiedAccessControlConditions: Object): Promise<ArrayBuffer>
Parameters
unifiedAccessControlConditions (Object) The unified access control conditions to hash.
Returns
Promise<ArrayBuffer>: A promise that resolves to an ArrayBuffer that contains the hash

HTML NFT Utilities

findLITs

Finds the tokens that the current user owns from the predeployed LIT contracts

findLITs(params: Object): array
Parameters
params (Object)
Name Description
params.chain string The chain that was minted on. "ethereum" and "polygon" are currently supported.
params.accountAddress number The account address to check
Returns
array: The token ids owned by the accountAddress

sendLIT

Send a token to another account

sendLIT(params: Object): Object
Parameters
params (Object)
Name Description
params.tokenMetadata string The token metadata of the token to be transferred. Should include tokenId, tokenAddress, and chain
params.to number The account address to send the token to
Returns
Object: Success or error

createHtmlLIT

Create a ready-to-go LIT using provided HTML/CSS body and an encrypted zip data url. You need to design your LIT with HTML and CSS, and provide an unlock button with the id "unlockButton" inside your HTML. This function will handle the rest.

createHtmlLIT(params: Object): Promise<string>
Parameters
params (Object)
Name Description
params.title string The title that will be used for the title tag in the outputted HTML
params.htmlBody number The HTML body for the locked state of the LIT. All users will be able to see this HTML. This HTML must have a button with an id of "unlockButton" which will be automatically set up to decrypt and load the encryptedZipDataUrl
params.css string Any CSS you would like to include in the outputted HTML
params.encryptedZipDataUrl number a data URL of the encrypted zip that contains the locked content that only token holders will be able to view.
params.chain string The chain that the corresponding NFT was minted on. "ethereum" and "polygon" are currently supported.
params.npmPackages Array (default []) An array of strings of NPM package names that should be embedded into this LIT. These packages will be pulled down via unpkg, converted to data URLs, and embedded in the LIT HTML. You can include any packages from npmjs.com.
params.tokenAddress string The token address of the corresponding NFT for this LIT. ERC721 and ERC 1155 tokens are currently supported.
params.tokenId number The ID of the token of the corresponding NFT for this LIT. Only holders of this token ID will be able to unlock and decrypt this LIT.
params.accessControlConditions any
params.encryptedSymmetricKey any
Returns
Promise<string>: A promise containing the HTML string that is now a LIT. You can send this HTML around and only token holders will be able to unlock and decrypt the content inside it. Included in the HTML is this LIT JS SDK itself, the encrypted locked content, an automatic connection to the LIT nodes network, and a handler for a button with id "unlockButton" which will perform the unlock operation when clicked.

mintLIT

This function mints a LIT using our pre-deployed token contracts. You may use our contracts, or you may supply your own. Our contracts are ERC1155 tokens on Polygon and Ethereum. Using these contracts is the easiest way to get started.

mintLIT(params: Object): Object
Parameters
params (Object)
Name Description
params.chain string The chain to mint on. "ethereum" and "polygon" are currently supported.
params.quantity number The number of tokens to mint. Note that these will be fungible, so they will not have serial numbers.
Returns
Object: The txHash, tokenId, tokenAddress, mintingAddress, and authSig.

unlockLitWithKey

Manually unlock a LIT with a symmetric key. You can obtain this key by calling "checkAndSignAuthMessage" to get an authSig, then calling "LitNodeClient.getEncryptionKey" to get the key. If you want to see an example, check out the implementation of "toggleLock" which does all those operations and then calls this function at the end (unlockLitWithKey)

unlockLitWithKey(params: Object): promise
Parameters
params (Object)
Name Description
params.symmetricKey Uint8Array The decryption key obtained by calling "LitNodeClient.getEncryptionKey"
Returns
promise: A promise that will resolve when the LIT is unlocked

toggleLock

Lock and unlock the encrypted content inside a LIT. This content is only viewable by holders of the NFT that corresponds to this LIT. Locked content will be decrypted and placed into the HTML element with id "mediaGridHolder". The HTML element with the id "lockedHeader" will have it's text automatically changed to LOCKED or UNLOCKED to denote the state of the LIT. Note that if you're creating a LIT using the createHtmlLIT function, you do not need to use this function, because this function is automatically bound to any button in your HTML with the id "unlockButton".

toggleLock(): Promise
Returns
Promise: the promise will resolve when the LIT has been unlocked or an error message has been shown informing the user that they are not authorized to unlock the LIT

injectViewerIFrame

Inject an iFrame into the current page that will display a LIT. This function safely sandboxes the content in the iFrame so that the LIT cannot see cookies or localStorage of the parent website.

injectViewerIFrame(params: Object)
Parameters
params (Object)
Name Description
params.destinationId Object The DOM ID of the element to inject the iFrame into
params.title string The title of the content being displayed
params.fileUrl string The URL of the content that will be shown in the iFrame
params.className string An optional DOM class name to add to the iFrame for styling

Types

AccessControlCondition

AccessControlCondition

Type: Object

Properties
contractAddress (string) : The address of the contract that will be queried
chain (string) : The chain name of the chain that this contract is deployed on. See LIT_CHAINS for currently supported chains.
standardContractType (string) : If the contract is an ERC20, ERC721, or ERC1155, please put that here
method (string) : The smart contract function to call
parameters (Array) : The parameters to use when calling the smart contract. You can use the special ":userAddress" parameter which will be replaced with the requesting user's wallet address, verified via message signature
returnValueTest (Object) : An object containing two keys: "comparator" and "value". The return value of the smart contract function will be compared against these. For example, to check if someone holds an NFT, you could use "comparator: >" and "value: 0" which would check that a user has a token balance greater than zero.

EVMContractCondition

EVMContractCondition

Type: Object

Properties
contractAddress (string) : The address of the contract that will be queried
chain (string) : The chain name of the chain that this contract is deployed on. See LIT_CHAINS for currently supported chains.
functionName (string) : The smart contract function to call
functionParams (Array) : The parameters to use when calling the smart contract. You can use the special ":userAddress" parameter which will be replaced with the requesting user's wallet address, verified via message signature
functionAbi (Object) : The ABI of the smart contract function to call. This is used to encode the function parameters and decode the return value of the function. Do not pass the entire contract ABI here. Instead, find the function you want to call in the contract ABI and pass that function's ABI here.
returnValueTest (Object) : An object containing three keys: "key", "comparator" and "value". The return value of the smart contract function will be compared against these. For example, to check if someone holds an NFT, you could use "key": "", "comparator: >" and "value: 0" which would check that a user has a token balance greater than zero. The "key" is used when the return value is a struct which contains multiple values and should be the name of the returned value from the function abi. You must always pass "key" when using "returnValueTest", even if you pass an empty string for it, because the function only returns a single value.

SolRpcCondition

SolRpcCondition

Type: Object

Properties
method (string) : The Solana RPC method to be called. You can find a list here: https://docs.solana.com/developing/clients/jsonrpc-api
params (Array) : The parameters to use when making the RPC call. You can use the special ":userAddress" parameter which will be replaced with the requesting user's wallet address, verified via message signature
chain (string) : The chain name of the chain that this contract is deployed on. See ALL_LIT_CHAINS for currently supported chains. On Solana, we support "solana" for mainnet, "solanaDevnet" for devnet and "solanaTestnet" for testnet.
returnValueTest (Object) : An object containing three keys: "key", "comparator" and "value". The return value of the rpc call will be compared against these. The "key" selector supports JSONPath syntax, so you can filter and iterate over the results. For example, to check if someone holds an NFT with address 29G6GSKNGP8K6ATy65QrNZk4rNgsZX1sttvb5iLXWDcE, you could use "method": "GetTokenAccountsByOwner", "params": [":userAddress",{"programId":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"encoding":"jsonParsed"}], "key": "$[?(@.account.data.parsed.info.mint == "29G6GSKNGP8K6ATy65QrNZk4rNgsZX1sttvb5iLXWDcE")].account.data.parsed.info.tokenAmount.amount", "comparator: >" and "value: 0" which would check that a user has a token balance greater than zero. The "key" is used when the return value is an array or object which contains multiple values and should be the name of the returned value or a JSONPath item. You must always pass "key" when using "returnValueTest", even if you pass an empty string for it, because the rpc call only returns a single value.

CosmosCondition

CosmosCondition

Type: Object

Properties
path (string) : The RPC URL path that will be called. This will typically contain any parameters you need for the call. Note that you can use the special ":userAddress" parameter which will be replaced with the requesting user's wallet address, verified via message signature. For example, this path would be used to get the requesting user's balance: "/cosmos/bank/v1beta1/balances/:userAddress"
chain (string) : The chain name of the chain that this contract is deployed on. See ALL_LIT_CHAINS for currently supported chains. On Cosmos we currently support "cosmos" and "kyve"
returnValueTest (Object) : An object containing three keys: "key", "comparator" and "value". The return value of the rpc call will be compared against these. The "key" selector supports JSONPath syntax, so you can filter and iterate over the results. For example, to check the balance of someone's account, you can use the key "$.balances[0].amount" which will pull out balances[0].amount from the JSON response and compare it against the "value" field according to the "comparator". The "key" is used when the return value is an array or object which contains multiple values and should be the name of the returned value or a JSONPath item. You must always pass "key" when using "returnValueTest", even if you pass an empty string for it, because the rpc call only returns a single value.

ResourceId

ResourceId

Type: Object

Properties
baseUrl (string) : The base url of the resource that will be authorized
path (string) : The path of the url of the resource that will be authorized
orgId (string) : The org id that the user would be authorized to belong to. The orgId key must be present but it may contain an empty string if you don't need to store anything in it.
role (string) : The role that the user would be authorized to have. The role key must be present but it may contain an empty string if you don't need to store anything in it.
extraData (string) : Any extra data you may want to store. You may store stringified JSON in here, for example. The extraData key must be present but it may contain an empty string if you don't need to store anything in it.

AuthSig

AuthSig

Type: Object

Properties
sig (string) : The actual hex-encoded signature
derivedVia (string) : The method used to derive the signature. Typically "web3.eth.personal.sign"
signedMessage (string) : The message that was signed
address (string) : The crypto wallet address that signed the message

Chain Info

LITChain

LITChain

Type: Object

Properties
vmType (string) : Either EVM for an Ethereum compatible chain or SVM for a Solana compatible chain
name (string) : The human readable name of the chain

LITEVMChain

LITEVMChain

Type: Object

Properties
contractAddress (string) : The address of the token contract for the optional predeployed ERC1155 contract. Only present on EVM chains.
chainId (string) : The chain ID of the chain that this token contract is deployed on. Used for EVM chains.
name (string) : The human readable name of the chain

LITSVMChain

LITSVMChain

Type: Object

Properties
name (string) : The human readable name of the chain

Misc

LITCosmosChain

LITCosmosChain

Type: Object

Properties
name (string) : The human readable name of the chain

LIT_CHAINS

EVM Chains supported by the LIT protocol. Each chain includes an optional pre-deployed token contract that you may use for minting LITs. These are ERC1155 contracts that let you mint any quantity of a given token. Use the chain name as a key in this object.

LIT_CHAINS

Type: LITEVMChain

LIT_SVM_CHAINS

Solana Chains supported by the LIT protocol. Use the chain name as a key in this object.

LIT_SVM_CHAINS

Type: LITSVMChain

LIT_COSMOS_CHAINS

Cosmos Chains supported by the LIT protocol. Use the chain name as a key in this object.

LIT_COSMOS_CHAINS

Type: LITCosmosChain

ALL_LIT_CHAINS

All Chains supported by the LIT protocol. Use the chain name as a key in this object.

ALL_LIT_CHAINS

Type: LITChain

getVarType

Get the type of a variable, could be an object instance type. eg Uint8Array instance should return 'Uint8Arrayas string or simply astringorint` type

getVarType
Parameters
value (any)
Returns
String: type

checkType

Check if the given value is the given type If not, throw invalidParamType error

checkType
Parameters
$0 (Object)
Name Description
$0.value any
$0.allowedTypes any
$0.paramName any
$0.functionName any
$0.throwOnError any (default true)
value (any)
allowedTypes (Array<String>)
paramName (string)
functionName (string)
throwOnError (boolean)
Returns
Boolean: true/false

downloadFile

Download a file in memory to the user's computer

downloadFile(params: Object): string
Parameters
params (Object)
Name Description
params.filename string The name of the file
params.data Uint8Array The actual file itself as a Uint8Array
params.mimetype string The mime type of the file
Returns
string: The data URL. This is a string representation that can be used anywhere the original file would be used.

importSymmetricKey

Import a symmetric key from a Uint8Array to a webcrypto key. You should only use this if you're handling your own key generation and management with Lit. Typically, Lit handles this internally for you.

importSymmetricKey(symmKey: Uint8Array): Promise<CryptoKey>
Parameters
symmKey (Uint8Array) The symmetric key to import
Returns
Promise<CryptoKey>: A promise that resolves to the imported key

generateSymmetricKey

Generate a new random symmetric key using WebCrypto subtle API. You should only use this if you're handling your own key generation and management with Lit. Typically, Lit handles this internally for you.

generateSymmetricKey(): Promise<CryptoKey>
Returns
Promise<CryptoKey>: A promise that resolves to the generated key

encryptWithPubKey

Encrypt a blob with the public key of a receiver

encryptWithPubKey(receiverPublicKey: string, data: Blob, version: string): Blob
Parameters
receiverPublicKey (string) The base64 encoded 32 byte public key. The corresponding private key will be able to decrypt this blob
data (Blob) The blob to encrypt
version (string) The encryption algorithm to use. This should be set to "x25519-xsalsa20-poly1305" as no other algorithms are implemented right now.
Returns
Blob: The encrypted blob

decryptWithPrivKey

Decrypt a blob with a private key

decryptWithPrivKey(encryptedData: Blob, receiverPrivateKey: string, version: string): Blob
Parameters
encryptedData (Blob) The blob to decrypt
receiverPrivateKey (string) The base64 encoded 32 byte private key. The corresponding public key was used to encrypt this blob
version (string) The encryption algorithm to use. This should be set to "x25519-xsalsa20-poly1305" as no other algorithms are implemented right now.
Returns
Blob: The decrypted blob

decimalPlaces

Get the number of decimal places in a token

decimalPlaces(params: Object): number
Parameters
params (Object)
Name Description
params.contractAddress string The token contract address
params.chain string The chain on which the token is deployed
Returns
number: The number of decimal places in the token

lookupNameServiceAddress

Lookup an eth address from a given ENS name

lookupNameServiceAddress(params: Object): string
Parameters
params (Object)
Name Description
params.chain string The chain on which to resolve the name
params.name string The name to resolve
Returns
string: The resolved eth address

metadataForFile

Get all the metadata needed to decrypt something in the future. If you're encrypting files with Lit and storing them in IPFS or Arweave, then this function will provide you with a properly formatted metadata object that you should save alongside the files.

metadataForFile(params: Object): Object
Parameters
params (Object)
Name Description
params.accessControlConditions Array The array of access control conditions defined for the object
params.chain string The blockchain on which the access control conditions should be checked
params.encryptedSymmetricKey Uint8Array The encrypted symmetric key that was returned by the LitNodeClient.saveEncryptionKey function
params.objectUrl string The url to the object, like an IPFS or Arweave url.
params.name any
params.type any
params.size any
params.evmContractConditions any
params.solRpcConditions any
params.unifiedAccessControlConditions any
Returns
Object: An object with 3 keys: "verified": A boolean that represents whether or not the token verifies successfully. A true result indicates that the token was successfully verified. "header": the JWT header. "payload": the JWT payload which includes the resource being authorized, etc.

configure

Get the final config object from any overrides Checks localStorage for override if browser client Stores config to globalThis.litConfig and return final config object

configure
Parameters
config (any) the override config object
Returns
any: overridden config

CallRequest

CallRequest

Type: Object

Properties
to (string) : The address of the contract that will be queried
from (string) : Optional. The address calling the function.
data (string) : Hex encoded data to send to the contract.