1.3.4
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
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.
(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. |
Crafts & signs the transaction using LitActions.signEcdsa() on the given chain
(Object)
Name | Description |
---|---|
params.to string
|
The "to" parameter in the transaction |
params.value string
|
The "value" parameter in the transaction |
params.data string
|
The "data" parameter in the transaction |
params.chain string
|
Used to get the "chainId" parameter in the transaction |
params.publicKey string
|
The publicKey used in the LitActions.signEcdsa() function |
params.gasPrice string
|
[Optional] The "gasPrice" parameter in the transaction |
params.gasLimit string
|
[Optional] The "gasLimit" parameter in the transaction |
Object
:
An object containing the resulting signature.
Signs & sends the transaction using the Provider on the given chain
(Object)
Name | Description |
---|---|
params.provider Object
|
The provider used to send the signed transaction to the appropriate network |
params.to string
|
The "to" parameter in the transaction |
params.value string
|
The "value" parameter in the transaction |
params.data string
|
The "data" parameter in the transaction |
params.chain string
|
Used to get the "chainId" parameter in the transaction |
params.publicKey string
|
The publicKey used in the LitActions.signEcdsa() function |
params.gasPrice string
|
[Optional] The "gasPrice" parameter in the transaction |
params.gasLimit string
|
[Optional] The "gasLimit" parameter in the transaction |
Object
:
A promise of the corresponding TransactionResponse.
Execute JS on the nodes and combine and return any resulting signatures
(Object)
Name | Description |
---|---|
params.code string
|
JS code to run on the nodes |
params.ipfsId string
|
The IPFS ID of some JS code to run on the nodes |
params.authSig AuthSig
|
the authSig to use to authorize the user with the nodes |
params.jsParams Object
(default {} )
|
An object that contains params to expose to the Lit Action. These will be injected to the JS runtime before your code runs, so you can use any of these as normal variables in your Lit Action. |
params.debug Boolean
|
A boolean that defines if debug info will be returned or not. |
params.sessionSigs any
|
|
params.authMethods any
(default [] )
|
Object
:
An object containing the resulting signatures. Each signature comes with the public key and the data signed.
Sign a session key using a PKP
(Object)
Name | Description |
---|---|
params.sessionKey string
|
The session key to sign |
params.authMethods Array<Object>
|
The auth methods to try for authenticating with the PKP. You must pass either at least 1 AuthMethod or an authSig |
params.pkpPublicKey Object
|
The PKP public key to use for signing |
params.authSig AuthSig
|
The authSig to use try for authenticating with the PKP. You must pass either at least 1 AuthMethod or an authSig |
params.expiration String
|
When this session signature will expire. The user will have to reauthenticate after this time using whatever auth method you set up. This means you will have to call this signSessionKey function again to get a new session signature. This is a RFC3339 timestamp. The default is 24 hours from now. |
params.resources any
(default [] )
|
|
params.chain any
|
Object
:
An object containing the resulting signature.
Request a signed JWT of any solidity function call from the LIT network. There are no prerequisites for this function. You should use this function if you need to transmit information across chains, or from a blockchain to a centralized DB or server. The signature of the returned JWT verifies that the response is genuine.
(Object)
Name | Description |
---|---|
params.callRequests Array<CallRequest>
|
The call requests to make. The responses will be signed and returned. |
params.chain string
|
The chain name of the chain that this contract is deployed on. See LIT_CHAINS for currently supported chains. |
Object
:
A signed JWT that proves the response to the function call is genuine. You may present this to a smart contract, or a server for authorization, and it can be verified using the verifyJwt function.
Request a signed JWT from the LIT network. Before calling this function, you must either create or know of a resource id and access control conditions for the item you wish to gain authorization for. You can create an access control condition using the saveSigningCondition function.
(Object)
Name | Description |
---|---|
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 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 you are querying. See ALL_LIT_CHAINS for currently supported chains. |
params.authSig AuthSig
|
The authentication signature that proves that the user owns the crypto wallet address that meets the access control conditions. |
params.resourceId ResourceId
|
The resourceId representing something on the web via a URL |
params.sessionSigs any
|
Object
:
A signed JWT that proves you meet the access control conditions for the given resource id. You may present this to a server for authorization, and the server can verify it using the verifyJwt function.
Associated access control conditions with a resource on the web. After calling this function, users may use the getSignedToken function to request a signed JWT from the LIT network. This JWT proves that the user meets the access control conditions, and is authorized to access the resource you specified in the resourceId parameter of the saveSigningCondition function.
(Object)
Name | Description |
---|---|
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 you are querying. See ALL_LIT_CHAINS for currently supported chains. |
params.authSig AuthSig
|
The authentication signature that proves that the user owns the crypto wallet address that meets the access control conditions |
params.resourceId ResourceId
|
The resourceId representing something on the web via a URL |
params.permanent boolean
(default true )
|
Whether or not the access control condition should be saved permanently. If false, the access control conditions will be updateable by the creator. If you don't pass this param, it's set to true by default. |
params.permanant any
|
|
params.sessionSigs any
|
boolean
:
Success
Retrieve the symmetric encryption key from the LIT nodes. Note that this will only work if the current user meets the access control conditions specified when the data was encrypted. That access control condition is typically that the user is a holder of the NFT that corresponds to this encrypted data. This NFT token address and ID was specified when this LIT was created.
(Object)
Name | Description |
---|---|
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.toDecrypt string
|
The ciphertext that you wish to decrypt encoded as a hex string |
params.chain string
|
The chain name of the chain that you are querying. See ALL_LIT_CHAINS for currently supported chains. |
params.authSig AuthSig
|
The authentication signature that proves that the user owns the crypto wallet address meets the access control conditions. |
params.sessionSigs any
|
Uint8Array
:
The symmetric encryption key that can be used to decrypt the locked content inside the LIT. You should pass this key to the decryptZip function.
Securely save the association between access control conditions and something that you wish to decrypt
(Object)
Name | Description |
---|---|
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 you are querying. See ALL_LIT_CHAINS for currently supported chains. |
params.authSig AuthSig
|
The authentication signature that proves that the user owns the crypto wallet address meets the access control conditions |
params.symmetricKey Uint8Array
|
The symmetric encryption key that was used to encrypt the locked content inside the LIT as a Uint8Array. You should use zipAndEncryptString or zipAndEncryptFiles to get this encryption key. This key will be hashed and the hash will be sent to the LIT nodes. You must pass either symmetricKey or encryptedSymmetricKey. |
params.encryptedSymmetricKey Uint8Array
|
The encrypted symmetric key of the item you with to update. You must pass either symmetricKey or encryptedSymmetricKey. |
params.permanent boolean
(default true )
|
Whether or not the access control condition should be saved permanently. If false, the access control conditions will be updateable by the creator. If you don't pass this param, it's set to true by default. |
params.permanant any
|
|
params.sessionSigs any
|
Uint8Array
:
The symmetricKey parameter that has been encrypted with the network public key. Save this - you will need it to decrypt the content in the future.
Validates a condition, and then signs the condition if the validation returns true. Before calling this function, you must know the on chain conditions that you wish to validate.
(Object)
Name | Description |
---|---|
params.accessControlConditions Array<AccessControlCondition>
|
The on chain control conditions that are to be evaluated and - if valid - signed. |
params.chain string
|
The chain name of the chain that you are querying. See ALL_LIT_CHAINS for currently supported chains. |
params.authSig AuthSig
|
The authentication signature that proves that the user owns the crypto wallet address that seeks to evaluate conditions. |
params.auth_sig any
|
Object
:
JSON structure with signed message, signature & public key..
Get session signatures for a set of resources
(Object)
Name | Description |
---|---|
params.expiration String
|
When this session signature will expire. The user will have to reauthenticate after this time using whatever auth method you set up. This means you will have to call this signSessionKey function again to get a new session signature. This is a RFC3339 timestamp. The default is 24 hours from now. |
params.chain String
|
The chain to use for the session signature. This is the chain that will be used to sign the session key. If you're using EVM then this probably doesn't matter at all. |
params.resources Array<String>
(default [] )
|
These are the resources that will be signed with the session key. You may pass a wildcard that allows these session signatures to work with any resource on Lit. To see a list of resources, check out the docs: https://developer.litprotocol.com/sdk/explanation/walletsigs/sessionsigs/#resources-you-can-request |
params.sessionCapabilityObject Array<String>
|
An optional capability object you want to request for this session. If you pass nothing, then this will default to a wildcard for each type of resource you're accessing. For example, if you passed ["litEncryptionCondition://123456"] then this would default to ["litEncryptionConditionCapability://*"], which would grant this session signature the ability to decrypt any resource. |
params.switchChain bool
|
If you want to ask Metamask to try and switch the user's chain, you may pass true here. This will only work if the user is using Metamask. If the user is not using Metamask, then this will be ignored. |
params.authNeededCallback Function
|
This is a callback that will be called if the user needs to authenticate using a PKP. For example, if the user has no wallet, but owns a Lit PKP though something like Google Oauth, then you can use this callback to prompt the user to authenticate with their PKP. This callback should use the LitNodeClient.signSessionKey function to get a session signature for the user from their PKP. If you don't pass this callback, then the user will be prompted to authenticate with their wallet, like metamask. |
params.sessionKey any
|
Object
:
An object containing the resulting signature.
Encrypt a string. This is used to encrypt any string that is to be locked via the Lit Protocol.
(string)
The string to encrypt
Promise<Object>
:
A promise containing the encryptedString as a Blob and the symmetricKey used to encrypt it, as a Uint8Array.
Decrypt a string that was encrypted with the encryptString function.
((Blob | File))
The encrypted string as a Blob
(Uint8Array)
The symmetric key used that will be used to decrypt this.
Promise<string>
:
A promise containing the decrypted string
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.
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.
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.
(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. |
Promise<ArrayBuffer>
:
A promise containing the decrypted file. The file is an ArrayBuffer.
Zip and encrypt a string. This is used to encrypt any string that is to be locked via the Lit Protocol.
(string)
The string to zip and encrypt
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"
Zip and encrypt multiple files.
(Array<File>)
An array of the files you wish to zip and encrypt
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.
Encrypt a single file, save the key to the Lit network, and then zip it up with the metadata.
(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. |
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.
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.
(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
|
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.
Encrypt a zip file created with JSZip using a new random symmetric key via WebCrypto.
(JSZip)
The JSZip instance to encrypt
Promise<Object>
:
A promise containing the encryptedZip as a Blob and the symmetricKey used to encrypt it, as a Uint8Array string.
Decrypt and unzip a zip that was created using encryptZip, zipAndEncryptString, or zipAndEncryptFiles.
((Blob | File))
The encrypted zip as a Blob
(Uint8Array)
The symmetric key used that will be used to decrypt this zip.
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')
Decrypt an encrypted blob with a symmetric key. Uses AES-CBC via SubtleCrypto
Blob
:
The decrypted blob
Encrypt a blob with a symmetric key
Blob
:
The encrypted blob
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.
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.
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.
(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. |
params.expiration String
|
Optional ISO 8601 datetime string you can use to set the expiration time on the SIWE message |
params.uri any
|
AuthSig
:
The AuthSig created or retrieved
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.
AuthSig
:
The AuthSig created or retrieved
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.
Convert a Blob to a base64urlpad string. Note: This function returns a promise.
((Blob | File))
The Blob or File to turn into a base64 string
Promise<String>
:
A promise that resolves to the base64 string
Convert a base64urlpad string to a Blob. Note: This function DOES NOT return a promise
(String)
The base64 string that to turn into a Blob
Blob
:
A blob that contains the decoded base64 data
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
(Uint8Array)
The Uint8Array to convert to a string
(String)
The encoding to use when converting the Uint8Array to a string.
String
:
The string representation of the Uint8Array
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
(String)
The string to convert to a Uint8Array
(String)
The encoding to use when converting the string to a Uint8Array.
String
:
The Uint8Array representation of the data from the string
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.
(File)
The file to turn into a data url
string
:
The data URL. This is a string representation that can be used anywhere the original file would be used.
The human readable name for an access control condition
(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
|
Promise<string>
:
A promise containing a human readable description of the access control conditions
Hash the unified access control conditions using SHA-256 in a deterministic way.
(Object)
The unified access control conditions to hash.
Promise<ArrayBuffer>
:
A promise that resolves to an ArrayBuffer that contains the hash
Finds the tokens that the current user owns from the predeployed LIT contracts
array
:
The token ids owned by the accountAddress
Send a token to another account
Object
:
Success or error
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.
(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
|
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.
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.
Object
:
The txHash, tokenId, tokenAddress, mintingAddress, and authSig.
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)
(Object)
Name | Description |
---|---|
params.symmetricKey Uint8Array
|
The decryption key obtained by calling "LitNodeClient.getEncryptionKey" |
promise
:
A promise that will resolve when the LIT is unlocked
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".
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
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.
(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 |
Type: Object
(string)
: The address of the contract that will be queried
(string)
: The chain name of the chain that this contract is deployed on. See LIT_CHAINS for currently supported chains.
(string)
: If the contract is an ERC20, ERC721, or ERC1155, please put that here
(string)
: The smart contract function to call
(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
(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.
Type: Object
(string)
: The address of the contract that will be queried
(string)
: The chain name of the chain that this contract is deployed on. See LIT_CHAINS for currently supported chains.
(string)
: The smart contract function to call
(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
(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.
(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.
Type: Object
(string)
: The Solana RPC method to be called. You can find a list here:
https://docs.solana.com/developing/clients/jsonrpc-api
(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
(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.
(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.
Type: Object
(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"
(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"
(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.
Type: Object
(string)
: The base url of the resource that will be authorized
(string)
: The path of the url of the resource that will be authorized
(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.
(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.
(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.
Type: Object
Type: Object
Type: Object
Type: Object
(string)
: The human readable name of the chain
Type: Object
(string)
: The human readable name of the chain
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.
Type: LITEVMChain
Solana Chains supported by the LIT protocol. Use the chain name as a key in this object.
Type: LITSVMChain
Cosmos Chains supported by the LIT protocol. Use the chain name as a key in this object.
Type: LITCosmosChain
All Chains supported by the LIT protocol. Use the chain name as a key in this object.
Type: LITChain
Get the type of a variable, could be an object instance type.
eg Uint8Array instance should return 'Uint8Arrayas string or simply a
stringor
int` type
(any)
String
:
type
Check if the given value is the given type
If not, throw invalidParamType
error
(Object)
Name | Description |
---|---|
$0.value any
|
|
$0.allowedTypes any
|
|
$0.paramName any
|
|
$0.functionName any
|
|
$0.throwOnError any
(default true )
|
(any)
(string)
(string)
(boolean)
Boolean
:
true/false
Convert types before sending to Lit Actions as jsParams.
(any)
Object
:
The jsParams object, but with any incompatible types automatically converted
Download a file in memory to the user's computer
(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 |
string
:
The data URL. This is a string representation that can be used anywhere the original file would be used.
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.
(Uint8Array)
The symmetric key to import
Promise<CryptoKey>
:
A promise that resolves to the imported key
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.
Promise<CryptoKey>
:
A promise that resolves to the generated key
Encrypt a blob with the public key of a receiver
(string)
The base64 encoded 32 byte public key. The corresponding private key will be able to decrypt this blob
(Blob)
The blob to encrypt
(string)
The encryption algorithm to use. This should be set to "x25519-xsalsa20-poly1305" as no other algorithms are implemented right now.
Blob
:
The encrypted blob
Decrypt a blob with a private key
(Blob)
The blob to decrypt
(string)
The base64 encoded 32 byte private key. The corresponding public key was used to encrypt this blob
(string)
The encryption algorithm to use. This should be set to "x25519-xsalsa20-poly1305" as no other algorithms are implemented right now.
Blob
:
The decrypted blob
Get the number of decimal places in a token
number
:
The number of decimal places in the token
Lookup an eth address from a given ENS name
string
:
The resolved eth address
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.
(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
|
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.
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
(any)
the override config object
any
:
overridden config
Type: Object