Skip to main content
Version: v3.x.x

Key Claiming

Prerequisites

Overview

Lit Actions have their own support for claiming which instead of using an auth method allows for using your own userId with the lit action's IPFS CID being the appId which allows for deriving custom claims which do not have to be derived through a support authentication method.

How it works

Instead of pre authenticating the access token within an Authentication Method claiming in a Lit Action allows you to define your own UserId and use the Actions IPFS CID to form the key identifier through your own user identifier. this will not require a pre authentication step which allows you to set up your own clams which can then be routed on chain withh our contract-sdk.

Example

  const res = await client.executeJs({
authSig,
code: `(async () => {
Lit.Actions.claimKey({keyId: userId});
})();`,
authMethods: [],
jsParams: {
userId: 'foo'
},
});

let client = new LitContracts(signer: "<your pkp wallet or other signer>");
let tx = await contractClient.pkpNftContract.write.claimAndMint(2, res.claims['foo'].derivedKeyId, res.claims['foo'].signatures);

adding an auth method when minting a claim

  const authMethod = {
authMethodType: AuthMethodType.EthWallet,
accessToken: JSON.stringify(authSig),
};

const authMethodId = LitAuthClient.getAuthMethodId(authMethod);

const res = await client.executeJs({
authSig,
code: `(async () => {
Lit.Actions.claimKey({keyId: userId});
})();`,
jsParams: {
userId: 'foo'
},
});

let client = new LitContracts(signer: "<your pkp wallet or other signer>");
let tx = await client.pkpHelperContract.write.claimAndMintNextAndAddAuthMethods(
res.claims['foo'],
{
keyType: 2,
permittedIpfsCIDs: [],
permittedIpfsCIDScopes: [],
permittedAddresses:: [],
permittedAddressScopes: [],
permittedAuthMethodTypes: [AuthMethodType.EthWallet],
permittedAuthMethodIds: [`0x${authMethodId}`],
permittedAuthMethodPubkeys: [`0x`],
permittedAuthMethodScopes: [[BigNumber.from("1")]],
addPkpEthAddressAsPermittedAddress: true,
sendPkpToItself: true
});