Constructors

Properties

allowlistContract: {
    read: Allowlist;
    write: Allowlist;
}
connected: boolean = false
debug: boolean = false
isPKP: boolean = false
litTokenContract: {
    read: LITToken;
    write: LITToken;
}
multisenderContract: {
    read: Multisender;
    write: Multisender;
}
options?: {
    storeOrUseStorageKey?: boolean;
}
pkpHelperContract: {
    read: PKPHelper;
    write: PKPHelper;
}
pkpHelperContractUtil: {
    read: {};
    write: {
        mintNextAndAddAuthMethods: ((param0: MintNextAndAddAuthMethods) => Promise<ContractTransaction>);
    };
} = ...

Type declaration

pkpNftContract: {
    read: PKPNFT;
    write: PKPNFT;
}
pkpNftContractUtils: {
    read: {
        getTokens: ((latestNumberOfTokens: number) => Promise<string[]>);
        getTokensByAddress: ((ownerAddress: string) => Promise<string[]>);
        getTokensInfoByAddress: ((ownerAddress: string) => Promise<TokenInfo[]>);
    };
    write: {
        claimAndMint: ((derivedKeyId: BytesLike, signatures: SignatureStruct[], txOpts?: CallOverrides) => Promise<{
            res: ContractReceipt;
            tokenId: any;
            tx: ContractTransaction;
        }>);
        mint: ((param?: GasLimitParam) => Promise<{
            pkp: {
                ethAddress: string;
                publicKey: string;
                tokenId: any;
            };
            res: any;
            tokenId: any;
            tx: ContractTransaction;
        }>);
    };
} = ...

Type declaration

  • read: {
        getTokens: ((latestNumberOfTokens: number) => Promise<string[]>);
        getTokensByAddress: ((ownerAddress: string) => Promise<string[]>);
        getTokensInfoByAddress: ((ownerAddress: string) => Promise<TokenInfo[]>);
    }
    • getTokens: ((latestNumberOfTokens: number) => Promise<string[]>)

      (IERC721Enumerable)

      Get the x latest number of tokens

        • (latestNumberOfTokens): Promise<string[]>
        • Parameters

          • latestNumberOfTokens: number

          Returns Promise<string[]>

          a list of PKP NFTs

    • getTokensByAddress: ((ownerAddress: string) => Promise<string[]>)

      (IERC721Enumerable)

      Get all PKPs by a given address

        • (ownerAddress): Promise<string[]>
        • Parameters

          • ownerAddress: string

          Returns Promise<string[]>

    • getTokensInfoByAddress: ((ownerAddress: string) => Promise<TokenInfo[]>)

      Get info of all PKPs by a given address

        • (ownerAddress): Promise<TokenInfo[]>
        • Parameters

          • ownerAddress: string

          Returns Promise<TokenInfo[]>

  • write: {
        claimAndMint: ((derivedKeyId: BytesLike, signatures: SignatureStruct[], txOpts?: CallOverrides) => Promise<{
            res: ContractReceipt;
            tokenId: any;
            tx: ContractTransaction;
        }>);
        mint: ((param?: GasLimitParam) => Promise<{
            pkp: {
                ethAddress: string;
                publicKey: string;
                tokenId: any;
            };
            res: any;
            tokenId: any;
            tx: ContractTransaction;
        }>);
    }
    • claimAndMint: ((derivedKeyId: BytesLike, signatures: SignatureStruct[], txOpts?: CallOverrides) => Promise<{
          res: ContractReceipt;
          tokenId: any;
          tx: ContractTransaction;
      }>)
        • (derivedKeyId, signatures, txOpts?): Promise<{
              res: ContractReceipt;
              tokenId: any;
              tx: ContractTransaction;
          }>
        • Parameters

          • derivedKeyId: BytesLike
          • signatures: SignatureStruct[]
          • txOpts: CallOverrides = {}

          Returns Promise<{
              res: ContractReceipt;
              tokenId: any;
              tx: ContractTransaction;
          }>

    • mint: ((param?: GasLimitParam) => Promise<{
          pkp: {
              ethAddress: string;
              publicKey: string;
              tokenId: any;
          };
          res: any;
          tokenId: any;
          tx: ContractTransaction;
      }>)
        • (param?): Promise<{
              pkp: {
                  ethAddress: string;
                  publicKey: string;
                  tokenId: any;
              };
              res: any;
              tokenId: any;
              tx: ContractTransaction;
          }>
        • Parameters

          Returns Promise<{
              pkp: {
                  ethAddress: string;
                  publicKey: string;
                  tokenId: any;
              };
              res: any;
              tokenId: any;
              tx: ContractTransaction;
          }>

pkpNftMetadataContract: {
    read: PKPNFTMetadata;
    write: PKPNFTMetadata;
}
pkpPermissionsContract: {
    read: PKPPermissions;
    write: PKPPermissions;
}
pkpPermissionsContractUtils: {
    read: {
        getPermittedActions: ((tokenId: BigNumberish) => Promise<string[]>);
        getPermittedAddresses: ((tokenId: string) => Promise<string[]>);
        isPermittedAction: ((pkpId: string, ipfsId: string) => Promise<boolean>);
        isPermittedAddress: ((tokenId: string, address: string) => Promise<boolean>);
    };
    write: {
        addPermittedAction: ((pkpId: string, ipfsId: string) => Promise<ContractTransaction>);
        addPermittedAddress: ((pkpId: string, ownerAddress: string) => Promise<ContractTransaction>);
        revokePermittedAction: ((pkpId: string, ipfsId: string) => Promise<ContractTransaction>);
    };
} = ...

Type declaration

  • read: {
        getPermittedActions: ((tokenId: BigNumberish) => Promise<string[]>);
        getPermittedAddresses: ((tokenId: string) => Promise<string[]>);
        isPermittedAction: ((pkpId: string, ipfsId: string) => Promise<boolean>);
        isPermittedAddress: ((tokenId: string, address: string) => Promise<boolean>);
    }
    • getPermittedActions: ((tokenId: BigNumberish) => Promise<string[]>)

      Get permitted action

        • (tokenId): Promise<string[]>
        • Parameters

          • tokenId: BigNumberish

          Returns Promise<string[]>

    • getPermittedAddresses: ((tokenId: string) => Promise<string[]>)

      Get permitted addresses

        • (tokenId): Promise<string[]>
        • Parameters

          • tokenId: string

          Returns Promise<string[]>

    • isPermittedAction: ((pkpId: string, ipfsId: string) => Promise<boolean>)

      Check if an action is permitted given the pkpid and ipfsId

        • (pkpId, ipfsId): Promise<boolean>
        • Parameters

          • pkpId: string

            103309008291725705563022469659474510532358692659842796086905702509072063991354

          • ipfsId: string

            QmZKLGf3vgYsboM7WVUS9X56cJSdLzQVacNp841wmEDRkW

          Returns Promise<boolean>

          transaction

    • isPermittedAddress: ((tokenId: string, address: string) => Promise<boolean>)

      Check if an address is permitted

        • (tokenId, address): Promise<boolean>
        • Parameters

          • tokenId: string
          • address: string

          Returns Promise<boolean>

  • write: {
        addPermittedAction: ((pkpId: string, ipfsId: string) => Promise<ContractTransaction>);
        addPermittedAddress: ((pkpId: string, ownerAddress: string) => Promise<ContractTransaction>);
        revokePermittedAction: ((pkpId: string, ipfsId: string) => Promise<ContractTransaction>);
    }
    • addPermittedAction: ((pkpId: string, ipfsId: string) => Promise<ContractTransaction>)

      Add permitted action to a given PKP id & ipfsId

        • (pkpId, ipfsId): Promise<ContractTransaction>
        • Parameters

          • pkpId: string

            103309008291725705563022469659474510532358692659842796086905702509072063991354

          • ipfsId: string

            QmZKLGf3vgYsboM7WVUS9X56cJSdLzQVacNp841wmEDRkW

          Returns Promise<ContractTransaction>

          transaction

    • addPermittedAddress: ((pkpId: string, ownerAddress: string) => Promise<ContractTransaction>)

      TODO: add transaction type Add permitted action to a given PKP id & ipfsId

        • (pkpId, ownerAddress): Promise<ContractTransaction>
        • Parameters

          • pkpId: string

            103309008291725705563022469659474510532358692659842796086905702509072063991354

          • ownerAddress: string

            0x3B5dD2605.....22aDC499A1

          Returns Promise<ContractTransaction>

          transaction

    • revokePermittedAction: ((pkpId: string, ipfsId: string) => Promise<ContractTransaction>)

      Revoke permitted action of a given PKP id & ipfsId

        • (pkpId, ipfsId): Promise<ContractTransaction>
        • Parameters

          • pkpId: string

            103309008291725705563022469659474510532358692659842796086905702509072063991354

          • ipfsId: string

            QmZKLGf3vgYsboM7WVUS9X56cJSdLzQVacNp841wmEDRkW

          Returns Promise<ContractTransaction>

          transaction

privateKey: string
provider: any
pubkeyRouterContract: {
    read: PubkeyRouter;
    write: PubkeyRouter;
}
randomPrivateKey: boolean = false
rateLimitNftContract: {
    read: RateLimitNFT;
    write: RateLimitNFT;
}
rateLimitNftContractUtils: {
    read: {
        getCapacityByIndex: ((index: number) => Promise<any>);
        getTokens: (() => Promise<any>);
        getTokensByOwnerAddress: ((ownerAddress: string) => Promise<any>);
        getTokenURIByIndex: ((index: number) => Promise<string>);
    };
    write: {
        mint: ((__namedParameters: {
            timestamp: number;
            txOpts: CallOverrides;
        }) => Promise<{
            tokenId: string;
            tx: ContractTransaction;
        }>);
        transfer: ((__namedParameters: {
            fromAddress: string;
            RLITokenAddress: string;
            toAddress: string;
        }) => Promise<ContractTransaction>);
    };
} = ...

Type declaration

  • read: {
        getCapacityByIndex: ((index: number) => Promise<any>);
        getTokens: (() => Promise<any>);
        getTokensByOwnerAddress: ((ownerAddress: string) => Promise<any>);
        getTokenURIByIndex: ((index: number) => Promise<string>);
    }
    • getCapacityByIndex: ((index: number) => Promise<any>)

      getCapacityByIndex: async (index: number): Promise => {

      This function takes a token index as a parameter and returns the capacity of the token with the given index. The capacity is an object that contains the number of requests per millisecond that the token allows, and an object with the expiration timestamp and formatted expiration date of the token.

        • (index): Promise<any>
        • Parameters

          • index: number

            The index of the token.

          Returns Promise<any>

          • A promise that resolves to the capacity of the token.

          Example:

          const capacity = await getCapacityByIndex(1); this.log(capacity); // Output: { // requestsPerMillisecond: 100, // expiresAt: { // timestamp: 1623472800, // formatted: '2022-12-31', // }, // }

          }

    • getTokens: (() => Promise<any>)

      getTokens: async (): Promise => {

      This function returns an array of all tokens that have been minted.

        • (): Promise<any>
        • Returns Promise<any>

          • A promise that resolves to an array of token objects.

          Example:

          const tokens = await getTokens(); this.log(tokens); // Output: [ // { // tokenId: 1, // URI: 'https://tokens.com/1', // capacity: 100, // isExpired: false, // }, // { // tokenId: 2, // URI: 'https://tokens.com/2', // capacity: 200, // isExpired: true, // }, // ... // ]

          }

    • getTokensByOwnerAddress: ((ownerAddress: string) => Promise<any>)

      getTokensByOwnerAddress: async (ownerAddress: string): Promise => {

      This function takes an owner address as a parameter and returns an array of tokens that are owned by the given address.

        • (ownerAddress): Promise<any>
        • Parameters

          • ownerAddress: string

            The address of the owner.

          Returns Promise<any>

          • A promise that resolves to an array of token objects.

          Example:

          const tokens = await getTokensByOwnerAddress('0x1234...5678'); this.log(tokens); // Output: [ // { // tokenId: 1, // URI: 'https://tokens.com/1', // capacity: 100, // isExpired: false, // }, // { // tokenId: 2, // URI: 'https://tokens.com/2', // capacity: 200, // isExpired: true, // }, // ... // ]

          }

    • getTokenURIByIndex: ((index: number) => Promise<string>)

      getTokenURIByIndex: async (index: number): Promise => {

      This function takes a token index as a parameter and returns the URI of the token with the given index.

        • (index): Promise<string>
        • Parameters

          • index: number

            The index of the token.

          Returns Promise<string>

          • A promise that resolves to the URI of the token.

          Example:

          const URI = await getTokenURIByIndex(1); this.log(URI); // Output: 'https://tokens.com/1'

          }

  • write: {
        mint: ((__namedParameters: {
            timestamp: number;
            txOpts: CallOverrides;
        }) => Promise<{
            tokenId: string;
            tx: ContractTransaction;
        }>);
        transfer: ((__namedParameters: {
            fromAddress: string;
            RLITokenAddress: string;
            toAddress: string;
        }) => Promise<ContractTransaction>);
    }
    • mint: ((__namedParameters: {
          timestamp: number;
          txOpts: CallOverrides;
      }) => Promise<{
          tokenId: string;
          tx: ContractTransaction;
      }>)
        • (__namedParameters): Promise<{
              tokenId: string;
              tx: ContractTransaction;
          }>
        • Parameters

          • __namedParameters: {
                timestamp: number;
                txOpts: CallOverrides;
            }
            • timestamp: number
            • txOpts: CallOverrides

          Returns Promise<{
              tokenId: string;
              tx: ContractTransaction;
          }>

    • transfer: ((__namedParameters: {
          fromAddress: string;
          RLITokenAddress: string;
          toAddress: string;
      }) => Promise<ContractTransaction>)

      Transfer RLI token from one address to another

        • (__namedParameters): Promise<ContractTransaction>
        • Parameters

          • __namedParameters: {
                fromAddress: string;
                RLITokenAddress: string;
                toAddress: string;
            }
            • fromAddress: string
            • RLITokenAddress: string
            • toAddress: string

          Returns Promise<ContractTransaction>

          void

routerContractUtils: {
    read: {};
    write: {};
} = ...
rpc: string
rpcs: string[]
signer: Wallet | Signer
stakingBalancesContract: {
    read: StakingBalances;
    write: StakingBalances;
}
stakingContract: {
    read: Staking;
    write: Staking;
}
utils: {
    decToHex: ((decStr: any, opts: any) => string);
    getBytes32FromMultihash: ((ipfsId: string, CID: CIDParser) => IPFSHash);
    getBytesFromMultihash: ((multihash: string) => string);
    getMultihashFromBytes: ((byte32: string) => string);
    hexToDec: ((hexStr: any) => string);
    timestamp2Date: ((timestamp: string) => string);
} = ...

Type declaration

  • decToHex: ((decStr: any, opts: any) => string)
      • (decStr, opts): string
      • Parameters

        • decStr: any
        • opts: any

        Returns string

  • getBytes32FromMultihash: ((ipfsId: string, CID: CIDParser) => IPFSHash)

    NOTE: This function requires the "multiformats/cid" package in order to work

    Partition multihash string into object representing multihash

    const CID = require('multiformats/cid')
    const ipfsId = 'QmZKLGf3vgYsboM7WVUS9X56cJSdLzQVacNp841wmEDRkW'
    const bytes32 = getBytes32FromMultihash(ipfsId, CID)
    console.log(bytes32)
      • (ipfsId, CID): IPFSHash
      • Parameters

        • ipfsId: string

          A base58 encoded multihash string

        • CID: CIDParser

          The CID object from the "multiformats/cid" package

        Returns IPFSHash

  • getBytesFromMultihash: ((multihash: string) => string)

    Partition multihash string into object representing multihash

      • (multihash): string
      • Parameters

        • multihash: string

          A base58 encoded multihash string

        Returns string

  • getMultihashFromBytes: ((byte32: string) => string)

    Convert bytes32 to IPFS ID

      • (byte32): string
      • Parameters

        • byte32: string

          0x1220baa0d1e91f2a22fef53659418ddc3ac92da2a76d994041b86ed62c0c999de477

        Returns string

        QmZKLGf3vgYsboM7WVUS9X56cJSdLzQVacNp841wmEDRkW

  • hexToDec: ((hexStr: any) => string)
      • (hexStr): string
      • Parameters

        • hexStr: any

        Returns string

  • timestamp2Date: ((timestamp: string) => string)
      • (timestamp): string
      • Parameters

        • timestamp: string

        Returns string

contractNames: (keyof ExclusiveLitContractContext)[] = ...
logger: Logger = ...

Methods

  • Adds a permitted action to the PKP permissions contract.

    Parameters

    Returns Promise<ContractReceipt>

    A promise that resolves to the result of the write operation.

    If an error occurs during the write operation.

  • Adds a permitted authentication method for a given PKP token.

    Parameters

    • params: {
          authMethodId: string | Uint8Array;
          authMethodScopes: AUTH_METHOD_SCOPE_VALUES[];
          authMethodType: number;
          pkpTokenId: string;
          webAuthnPubkey?: string;
      }

      The parameters for adding the permitted authentication method.

      • authMethodId: string | Uint8Array

        The ID of the authentication method.

      • authMethodScopes: AUTH_METHOD_SCOPE_VALUES[]

        The scopes of the authentication method.

      • authMethodType: number

        The type of the authentication method.

      • pkpTokenId: string

        The ID of the PKP token.

      • OptionalwebAuthnPubkey?: string

        The public key for WebAuthn.

    Returns Promise<ContractReceipt>

    • A promise that resolves with the result of adding the permitted authentication method.
    • If an error occurs while adding the permitted authentication method.
  • Retrieves the connection information for a given network.

    Parameters

    Returns Promise<{
        bootstrapUrls: string[];
        epochInfo: EpochInfo;
        minNodeCount: number;
        stakingContract: Contract;
    }>

    An object containing the staking contract, epoch number, minimum node count and an array of bootstrap URLs.

    Error if the minimum validator count is not set or if the active validator set does not meet the threshold.

  • Retrieves the Staking contract instance based on the provided network, context, and RPC URL. If a context is provided, it determines if a contract resolver is used for bootstrapping contracts. If a resolver address is present in the context, it retrieves the Staking contract from the contract resolver instance. Otherwise, it retrieves the Staking contract using the contract address and ABI from the contract context. Throws an error if required contract data is missing or if the Staking contract cannot be obtained.

    Parameters

    Returns Promise<Contract>

    The Staking contract instance.

    Error if required contract data is missing or if the Staking contract cannot be obtained.