Variable fhenixsdkConst

fhenixsdk: {
    createPermit: ((options?) => Promise<Result<PermitV2>>);
    encrypt: {
        <T>(item): Result<MappedEncryptedTypes<T>>;
        <T>(item): Result<[...MappedEncryptedTypes<T>]>;
    };
    encryptValue: ((value, type?, securityZone?) => Result<EncryptedNumber>);
    getAllPermits: (() => Result<Record<string, PermitV2>>);
    getPermission: ((hash?) => Result<{
        contracts: string[];
        expiration: number;
        issuer: string;
        issuerSignature: string;
        projects: string[];
        recipient: string;
        recipientSignature: string;
        sealingKey: string;
        validatorContract: string;
        validatorId: number;
    }>);
    getPermit: ((hash?) => Result<PermitV2>);
    importPermit: ((imported) => Promise<Result<PermitV2>>);
    initialize: ((params) => Promise<Result<undefined | PermitV2>>);
    selectActivePermit: ((hash) => Result<PermitV2>);
    store: StoreApi<SdkStore>;
    unseal: (<T>(item, account?, hash?) => Result<MappedUnsealedTypes<T>>);
    unsealCiphertext: ((ciphertext, account?, hash?) => Result<bigint>);
} = ...

Type declaration

  • createPermit: ((options?) => Promise<Result<PermitV2>>)
      • (options?): Promise<Result<PermitV2>>
      • Creates a new permit with options, prompts user for signature. Handles all permit.types, and prompts for the correct signature type. The created PermitV2 will be inserted into the store and marked as the active permit. NOTE: This is a wrapper around PermitV2.create and PermitV2.sign

        Parameters

        • Optional options: PermitV2Options

          Partial PermitV2 fields to create the Permit with, if no options provided will be filled with the defaults: { type: "self", issuer: initializedUserAddress, projects: initializedProjects, contracts: initializedContracts }

        Returns Promise<Result<PermitV2>>

        • Newly created PermitV2 as a Result object
  • encrypt: {
        <T>(item): Result<MappedEncryptedTypes<T>>;
        <T>(item): Result<[...MappedEncryptedTypes<T>]>;
    }
      • <T>(item): Result<MappedEncryptedTypes<T>>
      • Type Parameters

        • T

        Parameters

        • item: T

        Returns Result<MappedEncryptedTypes<T>>

      • <T>(item): Result<[...MappedEncryptedTypes<T>]>
      • Type Parameters

        • T extends any[]

        Parameters

        • item: [...T[]]

        Returns Result<[...MappedEncryptedTypes<T>]>

  • encryptValue: ((value, type?, securityZone?) => Result<EncryptedNumber>)
      • (value, type?, securityZone?): Result<EncryptedNumber>
      • Encrypts a numeric value according to the specified encryption type or the most efficient one based on the value. Useful when not using Encryptable utility structures.

        Parameters

        • value: number

          The numeric value to encrypt.

        • Optional type: EncryptionTypes

          Optional. The encryption type (uint8, uint16, uint32).

        • securityZone: number = 0

          The security zone for which to encrypt the value (default 0).

        Returns Result<EncryptedNumber>

        • The encrypted value serialized as Uint8Array. Use the .data property to access the Uint8Array.
  • getAllPermits: (() => Result<Record<string, PermitV2>>)
      • (): Result<Record<string, PermitV2>>
      • Exports all stored permits.

        Returns Result<Record<string, PermitV2>>

        • All stored permits.
  • getPermission: ((hash?) => Result<{
        contracts: string[];
        expiration: number;
        issuer: string;
        issuerSignature: string;
        projects: string[];
        recipient: string;
        recipientSignature: string;
        sealingKey: string;
        validatorContract: string;
        validatorId: number;
    }>)
      • (hash?): Result<{
            contracts: string[];
            expiration: number;
            issuer: string;
            issuerSignature: string;
            projects: string[];
            recipient: string;
            recipientSignature: string;
            sealingKey: string;
            validatorContract: string;
            validatorId: number;
        }>
      • Retrieves a stored permission based on the permit's hash. If no hash is provided, the currently active permit will be used. The PermissionV2 is extracted from the permit.

        Parameters

        • Optional hash: string

          Optional hash of the permission to get, defaults to active permit's permission

        Returns Result<{
            contracts: string[];
            expiration: number;
            issuer: string;
            issuerSignature: string;
            projects: string[];
            recipient: string;
            recipientSignature: string;
            sealingKey: string;
            validatorContract: string;
            validatorId: number;
        }>

        • The active permission or permission associated with hash, as a result object.
  • getPermit: ((hash?) => Result<PermitV2>)
      • (hash?): Result<PermitV2>
      • Retrieves a stored permit based on its hash. If no hash is provided, the currently active permit will be retrieved.

        Parameters

        • Optional hash: string

          Optional PermitV2.getHash of the permit.

        Returns Result<PermitV2>

        • The active permit or permit associated with hash as a Result object.
  • importPermit: ((imported) => Promise<Result<PermitV2>>)
      • (imported): Promise<Result<PermitV2>>
      • Imports a fully formed existing permit, expected to be valid. Does not ask for user signature, expects to already be populated. Will throw an error if the imported permit is invalid, see PermitV2.isValid. The imported PermitV2 will be inserted into the store and marked as the active permit.

        Parameters

        • imported: string | PermitV2Interface

          Permit to import as a text string or PermitV2Interface

        Returns Promise<Result<PermitV2>>

  • initialize: ((params) => Promise<Result<undefined | PermitV2>>)
      • (params): Promise<Result<undefined | PermitV2>>
      • Initializes the fhenixsdk to enable encrypting input data, creating permits / permissions, and decrypting sealed outputs. Initializes fhevm client FHE wasm module and fetches the provided chain's FHE publicKey. If a valid signer is provided, a permit/permission is generated automatically

        Parameters

        • params: InitParams & {
              generatePermit?: boolean;
              ignoreErrors?: boolean;
          }

        Returns Promise<Result<undefined | PermitV2>>

  • selectActivePermit: ((hash) => Result<PermitV2>)
      • (hash): Result<PermitV2>
      • Selects the active permit using its hash. If the hash is not found in the stored permits store, throws an error. The matched permit will be marked as the active permit.

        Parameters

        • hash: string

          The PermitV2.getHash of the target permit.

        Returns Result<PermitV2>

  • store: StoreApi<SdkStore>
  • unseal: (<T>(item, account?, hash?) => Result<MappedUnsealedTypes<T>>)
      • <T>(item, account?, hash?): Result<MappedUnsealedTypes<T>>
      • Uses the privateKey of permit.sealingPair to recursively unseal any contained SealedItems. If item is a single SealedItem it will be individually. NOTE: Only unseals typed SealedItems returned from FHE.sealoutputTyped and the FHE bindings' e____.sealTyped.

        Type Parameters

        • T

        Parameters

        • item: T

          Array, object, or item. Any nested SealedItems will be unsealed.

        • Optional account: string
        • Optional hash: string

        Returns Result<MappedUnsealedTypes<T>>

        • Recursively unsealed data in the target type, SealedBool -> boolean, SealedAddress -> string, etc.
  • unsealCiphertext: ((ciphertext, account?, hash?) => Result<bigint>)
      • (ciphertext, account?, hash?): Result<bigint>
      • Unseals an encrypted message using the stored permit for a specific contract address. NOTE: Wrapper around PermitV2.unseal

        Parameters

        • ciphertext: string

          The encrypted message to unseal.

        • Optional account: string

          Users address, defaults to store.account

        • Optional hash: string

          The hash of the permit to use for this operation, defaults to active permitV2 hash

        Returns Result<bigint>

        bigint - The unsealed message.