The Admin class is responsible for the ownership of the PKP (Programmable Key Pair), the registration and management of tools, policies, and delegatees.

Properties

litNetwork: LitNetwork

Methods

  • Adds a delegatee for the PKP.

    Parameters

    • pkpTokenId: string
    • delegatee: string

      The address to add as a delegatee.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Disables a tool for a given PKP.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • toolIpfsCid: string

      The IPFS CID of the tool to be disabled.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Disables a policy for a specific tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Enables a tool for a given PKP.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • toolIpfsCid: string

      The IPFS CID of the tool to be enabled.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Enables a policy for a specific tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Retrieves all policy parameters for a tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<any>

    A promise that resolves to an array of all policy parameter names and values.

    Throws

    If the tool policy registry contract is not initialized.

  • Retrieves all delegatees for the PKP.

    Parameters

    • pkpTokenId: string

    Returns Promise<string[]>

    An array of delegatee addresses.

    Throws

    If the tool policy registry contract is not initialized.

  • Gets all tools that are permitted for a specific delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<ToolInfoWithDelegateePolicy[]>

    A promise that resolves to an array of ToolInfoWithDelegateePolicy objects permitted for the delegatee.

    Throws

    If the tool policy registry contract is not initialized.

  • Retrieves a PKP by its token ID.

    Parameters

    • tokenId: string

      The token ID of the PKP.

    Returns Promise<PkpInfo>

    A promise that resolves to the PKP metadata.

    Throws

    If the PKP is not found in storage.

  • Get a registered tool by its IPFS CID for a given PKP.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • toolIpfsCid: string

      The IPFS CID of the tool to be retrieved.

    Returns Promise<any>

    A promise that resolves to the tool information.

    Throws

    If the tool policy registry contract is not initialized.

  • Get all registered tools and categorize them based on whether they have policies

    Parameters

    • pkpTokenId: string

    Returns Promise<RegisteredToolsResult>

    Object containing

    • toolsWithPolicies: Object mapping tool IPFS CIDs to their metadata and delegatee policies
    • toolsWithoutPolicies: Object mapping tool IPFS CIDs to their metadata without policies
    • toolsUnknownWithPolicies: Object mapping unknown tool IPFS CIDs to their delegatee policies
    • toolsUnknownWithoutPolicies: Array of tool CIDs without policies that aren't in the registry
  • Retrieves the policy for a specific tool and delegatee.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<{
        enabled: boolean;
        policyIpfsCid: string;
    }>

    An object containing the policy IPFS CID and enabled status for the tool.

    Throws

    If the tool policy registry contract is not initialized.

  • Retrieves a specific policy parameter for a tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    • parameterName: string

      The name of the policy parameter.

    Returns Promise<{
        name: string;
        value: string;
    }[]>

    A promise that resolves to the policy parameter value.

    Throws

    If the tool policy registry contract is not initialized.

  • Retrieves multiple policy parameters for a tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    • parameterNames: string[]

      An array of policy parameter names.

    Returns Promise<{
        name: string;
        value: string;
    }[]>

    A promise that resolves to an array of tuples containing policy parameter names and values.

    Throws

    If the tool policy registry contract is not initialized.

  • Checks if an address is a delegatee for the PKP.

    Parameters

    • pkpTokenId: string
    • delegatee: string

      The address to check.

    Returns Promise<any>

    A promise that resolves to a boolean indicating whether the address is a delegatee.

    Throws

    If the tool policy registry contract is not initialized.

  • Checks if a tool is permitted for a specific delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • toolIpfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<{
        isEnabled: any;
        isPermitted: any;
    }>

    A promise that resolves to an object containing isPermitted and isEnabled.

    Throws

    If the tool policy registry contract is not initialized.

  • Checks if a tool is registered for a given PKP.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • toolIpfsCid: string

      The IPFS CID of the tool to be checked.

    Returns Promise<{
        isEnabled: any;
        isRegistered: any;
    }>

    A promise that resolves to an object containing:

    • isRegistered: boolean indicating if the tool is registered
    • isEnabled: boolean indicating if the tool is enabled

    Throws

    If the tool policy registry contract is not initialized.

  • Permits a tool for a specific delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • toolIpfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Allows a tool to be used with the PKP.

    Parameters

    • pkpTokenId: string
    • ipfsCid: string

      The IPFS CID of the tool.

    • options: {
          enableTools?: boolean;
          signingScopes?: AUTH_METHOD_SCOPE_VALUES[];
      } = {}
      • Optional enableTools?: boolean
      • Optional signingScopes?: AUTH_METHOD_SCOPE_VALUES[]

    Returns Promise<{
        litContractsTxReceipt: ContractReceipt;
        toolRegistryContractTxReceipt: any;
    }>

    A promise that resolves to the transaction receipt.

    Throws

    If the Admin instance is not properly initialized.

  • Removes a delegatee for the PKP.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • delegatee: string

      The address of the delegatee to remove.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Removes a tool from the list of a PKP's permitted tools.

    Parameters

    • pkpTokenId: string
    • ipfsCid: string

      The IPFS CID of the tool.

    Returns Promise<{
        removeToolsTxReceipt: any;
        revokePermittedActionTxReceipt: ContractReceipt;
    }>

    A promise that resolves to the transaction receipt.

    Throws

    If the Admin instance is not properly initialized.

  • Removes a policy for a specific tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Removes multiple policy parameters for a tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    • parameterNames: string[]

      An array of policy parameter names to remove.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Sets or updates a policy for a specific tool and delegatee.

    Parameters

    • pkpTokenId: string

      The token ID of the PKP.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    • policyIpfsCid: string

      The IPFS CID of the policy to be set.

    • enablePolicies: boolean

      Whether to enable the policy after setting it.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Sets multiple policy parameters for a tool and delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • ipfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    • parameterNames: string[]

      An array of policy parameter names.

    • parameterValues: any[]

      An array of policy parameter values.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Transfers ownership of the PKP to a new owner.

    Parameters

    • pkpTokenId: string
    • newOwner: string

      The address of the new owner.

    Returns Promise<ContractReceipt>

    A promise that resolves to the transaction receipt.

    Throws

    If the Admin instance is not properly initialized.

  • Unpermits a tool for a specific delegatee.

    Parameters

    • pkpTokenId: string

      The PKP token ID.

    • toolIpfsCid: string

      The IPFS CID of the tool.

    • delegatee: string

      The address of the delegatee.

    Returns Promise<any>

    A promise that resolves to the transaction receipt.

    Throws

    If the tool policy registry contract is not initialized.

  • Creates an instance of the Admin class. Initializes the Lit node client, contracts, and PKP.

    Parameters

    • adminConfig: AdminConfig

      Configuration for the Admin role.

    • agentConfig: AgentConfig = {}

      Configuration for the agent, including the Lit network and debug mode.

    Returns Promise<Admin>

    A promise that resolves to an instance of the Admin class.

    Throws

    If the Lit network is not provided or the private key is missing.