@portal-hq/core package is the main entry point for integrating Portal’s MPC wallet infrastructure into your React Native application. It includes the Portal class, React Context utilities (PortalContextProvider, usePortal), and exports for types, enums, and error handling.
Installation
The Portal Class
ThePortal class is the primary interface for interacting with Portal’s MPC wallet infrastructure.
Properties
| Property | Type | Description |
|---|---|---|
api | IPortalApi | Portal API client for REST API interactions |
apiKey | string | Your Portal Client API Key |
backup | BackupOptions | Configured backup storage adapters |
chainId | number | Deprecated. Default chain ID (default: 11155111) |
featureFlags | FeatureFlags | Feature flag configuration |
gatewayConfig | GatewayLike | Gateway/RPC configuration |
mpc | PortalMpc | MPC operations client |
provider | IPortalProvider | EIP-1193 compliant provider |
trading | Trading | Trading module for Li.Fi and 0x integrations |
yield | Yield | Yield module for Yield.xyz integration |
Getters
| Getter | Type | Description |
|---|---|---|
address | Promise<string | undefined> | The primary wallet address (EIP-155) |
addresses | Promise<AddressesByNamespace | undefined> | All wallet addresses by namespace |
autoApprove | boolean | Whether auto-approve is enabled |
Constructor
PortalOptions
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | - | Portal Client API Key |
backup | BackupOptions | Yes | - | Backup storage adapters keyed by BackupMethods |
gatewayConfig | GatewayLike | Yes | - | RPC URL string or chain-specific config object |
chainId | number | No | 11155111 | Deprecated. Default chain ID for EVM chains |
isSimulator | boolean | No | false | Running in simulator/emulator |
autoApprove | boolean | No | false | Auto-approve signing requests |
keychain | KeychainAdapter | No | new Keychain() | Keychain storage adapter |
apiHost | string | No | 'api.portalhq.io' | Portal API host |
mpcHost | string | No | 'mpc.portalhq.io' | MPC server host |
enclaveMPCHost | string | No | 'mpc-client.portalhq.io' | Enclave MPC host |
webSocketHost | string | No | 'connect.portalhq.io' | WebSocket host for Portal Connect |
version | string | No | 'v6' | MPC version (only 'v6' is supported) |
featureFlags | FeatureFlags | No | {} | Feature flags |
Wallet Management Methods
createWallet
Creates a new MPC wallet with both SECP256K1 (EVM) and ED25519 (Solana) key pairs.
| Parameter | Type | Required | Description |
|---|---|---|---|
progress | ProgressCallback | No | Callback for progress updates |
backupWallet
Creates encrypted backup shares for the wallet.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | BackupMethods | Yes | Backup storage method |
progress | ProgressCallback | No | Progress callback |
backupConfig | BackupConfigs | No | Additional config (e.g., password) |
recoverWallet
Recovers a wallet from backup shares.
| Parameter | Type | Required | Description |
|---|---|---|---|
cipherText | string | No | Encrypted backup string. Leave empty (”) or omit for cloud backups (Google Drive, iCloud). Required for local/password backups. |
method | BackupMethods | Yes | Backup method used |
progress | ProgressCallback | No | Progress callback |
backupConfig | BackupConfigs | No | Additional config |
provisionWallet
Alias for recoverWallet. Provisions a wallet on a new device.
Wallet State Methods
doesWalletExist
Checks if a wallet exists on the Portal backend.
isWalletOnDevice
Checks if wallet signing shares exist on the current device.
isWalletBackedUp
Checks if the wallet has a completed backup.
isWalletRecoverable
Checks if the wallet can be recovered (has at least one backup method).
availableRecoveryMethods
Returns the list of backup methods available for recovery.
getAssets
Fetches the wallet assets for a given chain, including native balance, ERC20 token balances, and NFTs (if available).
Note: The nfts field will only be included if the request is made with the includeNfts=true query parameter. Otherwise, it may be undefined or omitted, even on chains that support NFTs.
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain identifier (e.g., 'eip155:1') |
nfts field may be undefined depending on the chain and whether NFTs are supported.
Example:
Signing Methods
personalSign
Signs a message using personal_sign.
ethSign
Signs a message using eth_sign.
ethSignTypedData
Signs typed data (EIP-712) using eth_signTypedData_v4.
rawSign
Signs raw data without any prefix.
Transaction Methods
ethSendTransaction
Sends a signed transaction to the network.
ethSignTransaction
Signs a transaction without broadcasting.
sendAsset
High-level method to send tokens or native assets.
Signature (Recommended):
SendAssetParams
| Parameter | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient address |
token | string | Yes | Token symbol (e.g., 'ETH', 'USDC', 'SOL') |
amount | string | Yes | Amount to send |
sponsorGas | boolean | No | Whether Portal should sponsor the gas. Only applies when the client has Account Abstraction (AA) enabled and the chain is supported. Omitting this field maintains backward compatibility. |
chain | string | No | Chain identifier (friendly name, CAIP-2, or uses default chainId) |
- Friendly names:
'ethereum','sepolia','base','base-sepolia','polygon','polygon-mumbai','polygon-amoy','solana','solana-devnet','optimism','arbitrum','avalanche' - CAIP-2 format:
'eip155:1','eip155:11155111','solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', etc. - If omitted and no default
chainIdis set, an error will be thrown
evaluateTransaction
Evaluates a transaction for security risks using Blockaid.
Provider Methods
request
Generic method to make JSON-RPC requests.
| Parameter | Type | Required | Description |
|---|---|---|---|
method | string | Yes | JSON-RPC method name |
params | unknown[] | SigningRequestParams | Yes | Method parameters |
chainId | string | No | CAIP-2 chain identifier |
options | RequestOptions | No | Request options (e.g., { sponsorGas: boolean }) |
sponsorGas(boolean, optional): Whether Portal should sponsor gas. Only applies when the client has Account Abstraction (AA) enabled and the chain is supported. Omitting this field maintains default behavior.
ethGetBalance
Gets the native token balance.
ethGasPrice
Gets the current gas price.
ethEstimateGas
Estimates gas for a transaction.
getBalanceAsNumber
Gets the native token balance as a number (in ETH, not wei).
updateChain (Deprecated)
Updates the current chain ID for the provider.
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId | string | Yes | CAIP-2 chain identifier (e.g., 'eip155:137') |
Event Methods
on
Subscribes to provider events.
emit
Emits a provider event.
removeEventListener
Removes an event listener.
Keychain Methods
deleteAddress
Deletes the stored address from keychain.
deleteSigningShare
Deletes the signing share from keychain.
deleteShares
Deletes all shares from keychain.
Share Metadata Methods
getSigningSharesMetadata
Gets metadata about signing share pairs.
getBackupSharesMetadata
Gets metadata about backup share pairs.
Testnet Methods
receiveTestnetAsset
Requests testnet tokens from the Portal faucet.
Portal Connect
createPortalConnectInstance
Creates a Portal Connect instance for WalletConnect integration.
The portal.api Object
The api property provides access to Portal’s REST API.
getClient
Gets the current client information.
getAssets
Fetches native balance, token balances, and NFTs for the wallet on a specific chain.
getNFTs
Fetches NFTs owned by the wallet.
getBalances
Fetches ERC20 token balances.
getTransactions
Fetches transaction history.
getNetworks
Gets supported networks.
getEnabledDapps
Gets enabled dApps for the client.
simulateTransaction
Simulates a transaction.
getQuote (Deprecated)
Deprecated: Use portal.trading.zeroX.getQuote() instead.
Gets a swap quote.
getSources (Deprecated)
Deprecated: Use portal.trading.zeroX.getSources() instead.
Gets available swap sources.
The portal.mpc Object
The mpc property handles MPC wallet operations directly.
generate
Generates new MPC signing shares.
backup
Creates backup shares.
recover
Recovers signing shares from backup.
ejectPrivateKey
Ejects the SECP256K1 private key (for migration).
| Parameter | Type | Required | Description |
|---|---|---|---|
backupShareCipherText | string | No | Encrypted backup share (default: '') |
backupMethod | BackupMethods | Yes | Backup method to use |
backupConfig | BackupConfigs | No | Backup configuration |
orgShare | string | No | Organization share (default: '') |
ejectPrivateKeys
Ejects both SECP256K1 and ED25519 private keys.
| Parameter | Type | Required | Description |
|---|---|---|---|
backupShareCipherText | string | No | Encrypted backup share (default: '') |
backupMethod | BackupMethods | Yes | Backup method to use |
backupConfig | BackupConfigs | No | Backup configuration |
orgShare | orgShares | No | Organization shares (default: { secp256k1: '', ed25519: '' }) |
reset
Resets local wallet data.
isReady
Checks if the MPC client is ready.
The portal.provider Object
The provider property is an EIP-1193 compliant provider.
request
Makes JSON-RPC requests.
React Context
PortalContextProvider
Provides the Portal instance to child components.
usePortal
Hook to access the Portal instance.
Enums
BackupMethods
PortalNamespace
PortalCurve
PortalSharePairStatus
MpcErrorCodes
EvaluateTransactionOperationType
Error Classes
MpcError
Custom error class for MPC operations.
Types
PortalOptions
BackupOptions
FeatureFlags
| Property | Type | Default | Description |
|---|---|---|---|
enableSdkPerformanceMetrics | boolean | false | Enable SDK performance metrics tracking |
isMultiBackupEnabled | boolean | undefined | Enable multiple backup methods |
useEnclaveMPCApi | boolean | false | Use Enclave MPC API instead of standard MPC |