Overview
TheFeatureFlags data class is used to configure feature flags when initializing the Portal SDK. Each flag corresponds to a specific feature or behavior that can be toggled on or off.
Example Usage:
Available Feature Flags
Below is a list of available feature flags and their functionality.1. useEnclaveMpcApi
- Type:
Boolean? - Default:
null(disabled) - Description: Enables the use of the Enclave MPC API for signing transactions. When enabled, MPC operations are executed server-side in a secure AWS Nitro Enclave, ensuring consistent and faster signing times.
useEnclaveMpcApi flag, the client key share is transmitted to a Trusted Execution Environment (TEE) hosted in an AWS Nitro Enclave. This ensures:
- Encrypted Memory: All data processed in the enclave is encrypted and inaccessible to anyone, including Portal employees.
- Verified Execution: Users can cryptographically verify that their request was handled in a secure enclave using signed measurements.
useEnclaveMpcApi to true, the Portal instance will use the Enclave MPC API for signing transactions, ensuring faster computation and consistent performance across client devices.
usePreGeneratedWallet
- Type:
Boolean? - Default:
null(disabled) - Description: When enabled,
portal.createWallet()attempts to claim a pre-generated wallet share instead of running the standard interactive MPC generation. This can make wallet creation faster. You do not need to change how you callcreateWallet.
createWallet runs the MPC key generation (DKG) protocol interactively between the device and the MPC servers at the moment it is called. With this flag enabled, the SDK asks the enclave for a share from a pre-computed pool instead.
Two separate fallbacks protect that path, and it helps to keep them apart:
- Enclave-side fallback—if the pool is empty, or the eligibility check can’t be completed, the enclave generates the shares on demand and returns them in the same successful response. Your app sees an ordinary success, and the device still skips the DKG protocol.
- SDK-side fallback—if the request fails with an HTTP 5xx, the SDK falls back to running the standard DKG protocol on the device. This is transparent too:
createWalletreturns the sameResultit would through the standard flow.
Result.
Claiming a share does not change the security model: shares are still split between the user’s device and Portal, and the pre-generated shares are produced in the same Trusted Execution Environment described in the
useEnclaveMpcApi section above.
Checking the fallback rule yourself
The policy is driven by a public helper, Mpc.isRetryableServerError(error: Throwable), which returns true only for a PortalException.Api.HttpRequestFailed carrying a 5xx status. Every other throwable—including other PortalException.Api types and IOException—returns false. It is useful for asserting the classification in your own tests:
Result, the SDK has already made the fallback decision, so this helper predicts nothing about an error you receive from onFailure. See Error handling for the full PortalException hierarchy.
When to enable
Enable usePreGeneratedWallet when you want faster wallet creation without changing your integration. It helps most on lower-end devices, where running the DKG protocol on the handset is slowest and least consistent. The resulting wallet is identical to one created through the standard flow.
Limitations
- This is a performance optimization only; it doesn’t change the API surface, the resulting wallet, or how backup and recovery work.
- An empty pool isn’t something your app has to handle: the enclave covers it by generating on demand, so it never reaches the SDK as an error.
- SDK-side fallback to the on-device protocol occurs on an HTTP 5xx response from the enclave only. A 4xx rejection (such as
Wallet already exists), an unauthorized API key, and network failures propagate normally—so a misconfigured API key produces a failed wallet creation rather than a slow one. Keep your existing error handling aroundcreateWallet.
FeatureFlags is optional and defaults to null, so you can enable usePreGeneratedWallet on its own as shown above, or alongside any other flag.
Types
Claiming a share calls the Enclave MPC API at POST https://{enclaveApiHost}/v1/generate, where enclaveApiHost is a Portal constructor parameter that defaults to mpc-client.portalhq.io. The request and response types are public so you can build mocks and tests against them—most integrations never reference them directly, since createWallet handles the response for you.