Skip to main content
The @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

The Portal class is the primary interface for interacting with Portal’s MPC wallet infrastructure.

Properties

Getters

Constructor

PortalOptions


Wallet Management Methods

createWallet

Creates a new MPC wallet with both SECP256K1 (EVM) and ED25519 (Solana) key pairs.
Parameters: Example:

backupWallet

Creates encrypted backup shares for the wallet.
Parameters: Example:

recoverWallet

Recovers a wallet from backup shares.
Parameters: Example:

provisionWallet

Alias for recoverWallet. Provisions a wallet on a new device.

Wallet State Methods

doesWalletExist

Checks if a wallet exists on the Portal backend.
Example:

isWalletOnDevice

Checks if wallet signing shares exist on the current device.
Example:

isWalletBackedUp

Checks if the wallet has a completed backup.
Example:

isWalletRecoverable

Checks if the wallet can be recovered (has at least one backup method).
Example:

availableRecoveryMethods

Returns the list of backup methods available for recovery.
Example:

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.
Parameters: Returns:
Note: The nfts field may be undefined depending on the chain and whether NFTs are supported. Example:

Signing Methods

personalSign (Deprecated)

Signs a message using personal_sign.
Deprecated: Use request(PortalRequestMethod.PersonalSign, [message, address], chainId, options) instead.
You can pass { signatureApprovalMemo: 'your memo' } in the options.
Example (Deprecated):
Recommended approach:

ethSign (Deprecated)

Signs a message using eth_sign.
Deprecated: This method still supports the signature ethSign(message, chainId?, signatureApprovalMemo?), where signatureApprovalMemo is an optional memo shown in the signing UI.
The recommended approach is to use request(PortalRequestMethod.EthSign, [address, message], chainId, { signatureApprovalMemo: 'your memo' }) instead.
Example (Deprecated):
Recommended approach:

ethSignTypedData (Deprecated)

Signs typed data (EIP-712) using eth_signTypedData_v4.
Deprecated: Use request(PortalRequestMethod.EthSignTypedDataV4, [address, typedData], chainId, options) instead.
You can pass { signatureApprovalMemo: 'your memo' } in the options.
Example (Deprecated):
Recommended approach:

rawSign

Signs raw data without any prefix.
Example:

Transaction Methods

ethSendTransaction (Deprecated)

Sends a signed transaction to the network.
Deprecated: Use request(PortalRequestMethod.EthSendTransaction, [transaction], chainId, options) instead.
You can pass { sponsorGas: boolean, signatureApprovalMemo: 'your memo' } in the options.
Example (Deprecated):
Recommended approach:

ethSignTransaction (Deprecated)

Signs a transaction without broadcasting.
Deprecated: Use request(PortalRequestMethod.EthSignTransaction, [transaction], chainId, options) instead.
You can pass { signatureApprovalMemo: 'your memo' } in the options.
Example (Deprecated):
Recommended approach:

sendAsset

High-level method to send tokens or native assets. Recommended Signature:
Deprecated Signature:
Note: The positional parameters signature sendAsset(to, token, amount, chain) is deprecated. Use the object-based signature sendAsset({ to, token, amount, sponsorGas, signatureApprovalMemo }, chain) instead.

SendAssetParams

Parameters: Supported chain values:
  • Friendly names:
    • 'ethereum', 'sepolia', 'base', 'base-sepolia'
    • 'polygon', 'polygon-mumbai', 'polygon-amoy'
    • 'solana', 'solana-devnet'
    • 'optimism', 'arbitrum', 'avalanche'
    • 'bitcoin-p2wpkh', 'bitcoin-p2wpkh-testnet'
  • CAIP-2 format:
    • EVM chains: 'eip155:1', 'eip155:11155111', etc.
    • Solana: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', etc.
    • Bitcoin (bip122 namespace):
      • 'bip122:000000000019d6689c085ae165831e93-p2wpkh'
      • 'bip122:000000000933ea01ad0ee984209779ba-p2wpkh'
  • If omitted and no default chainId is set, an error will be thrown
Example:

waitForConfirmation

Waits until a transaction is confirmed on the blockchain using strict confirmation semantics. Only a true return value indicates confirmed success. Behavior by chain type:
  • EVM chains (eip155:*): Polls eth_getTransactionReceipt and (when applicable) eth_getUserOperationReceipt against your configured gatewayConfig URL
  • Solana chains (solana:*): Polls getSignatureStatuses with confirmed commitment level against your configured gatewayConfig URL
  • Unsupported/other chains: Returns false (not supported)
This is the default confirmation strategy used between transaction steps in portal.yield.yieldxyz.deposit(), portal.yield.yieldxyz.withdraw(), and portal.trading methods.
Parameters: Returns:
  • true — Transaction confirmed successfully on-chain
  • false — Timeout, transaction failed on-chain, or unsupported network
Configuration: Default behavior:
  • Poll interval: 4 seconds (4_000ms)
  • Timeout: 15 minutes (900_000ms)
  • On timeout or failure: Returns false (does not throw)
Strict confirmation contract: Only waitForConfirmation(...) === true should be treated as success. Any other value (false, timeout, unsupported network) indicates failure. When used by Portal SDK methods (Yield, LiFi, 0x), this strict contract determines whether execution continues or stops. Example:

evaluateTransaction

Evaluates a transaction for security risks using Blockaid.
Example:

Provider Methods

request

Generic method to make JSON-RPC requests. Preferred Signature:
Deprecated Signature:
Note: Using raw string methods is deprecated. Use the PortalRequestMethod enum instead for type safety and better IDE support.
Parameters: RequestOptions:
  • 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.
  • signatureApprovalMemo (string, optional): Optional memo displayed to the user during the signature approval flow.
Example:

ethGetBalance (Deprecated)

Gets the native token balance.
Deprecated: Use request(PortalRequestMethod.EthGetBalance, [address], chainId) instead.
Recommended approach:

ethGasPrice (Deprecated)

Gets the current gas price.
Deprecated: Use request(PortalRequestMethod.EthGasPrice, [], chainId) instead.
Recommended approach:

ethEstimateGas (Deprecated)

Estimates gas for a transaction.
Deprecated: Use request(PortalRequestMethod.EthEstimateGas, [transaction], chainId) instead.
Recommended approach:

getBalanceAsNumber

Gets the native token balance as a number (in ETH, not wei).
Example:

updateChain (Deprecated)

Updates the current chain ID for the provider.
Parameters: Example:

Event Methods

on

Subscribes to provider events.
Example:

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.
Example:

Portal Connect

createPortalConnectInstance

Creates a Portal Connect instance for WalletConnect integration.
Example:

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

Deprecated: Use portal.api.getNftAssets() instead.
Fetches NFTs owned by the wallet.
Example:

getBalances

Deprecated: Use portal.getAssets() instead.
Fetches ERC20 token balances.
Example:

getNftAssets

Gets NFT assets held by the wallet.
Parameters Returns Promise<NFTAsset[]> - Array of NFT assets Example Usage

getTransactionHistory

Returns the transaction history for a wallet across supported chains. Replaces the legacy getTransactions method with pagination and extended support for modern transaction types (including ERC-4337 UserOperations on EVM chains). EVM responses use the normalized format documented below, while Solana currently returns its legacy response shape and will be unified in a future update.
Parameters Default behavior (userOperations)
  • EVM (eip155:*) — If the authenticated client has Account Abstraction enabled (isAccountAbstracted), the SDK automatically sends userOperations=only. If the client is an EOA, the SDK does not send the parameter.
  • Non-EVM chains (e.g. solana:*, Bitcoin, Tron, Stellar) — The SDK never injects userOperations; the filter does not apply to those namespaces.
If userOperations is provided, it always overrides this behavior. Returns Promise<GetTransactionHistoryResponse> For Solana chains (solana:*):
For EVM, Bitcoin, Tron, Stellar chains:
TransactionHistoryItem is a discriminated union:
  • RegularTransaction: type: 'transaction' with optional token metadata (asset, tokenAddress, tokenDecimals)
  • UserOperationTransaction: type: 'userOperation' with UserOp fields (userOpHash, entryPoint, actualGasCost, actualGasUsed)
Example Usage

getTransactions

Deprecated: Use portal.api.getTransactionHistory() instead, which provides improved type safety with discriminated unions for regular transactions and UserOperations, and proper polymorphic response types for Solana vs unified formats.
Fetches transaction history.
Example:

getNetworks

Gets supported networks.

getEnabledDapps

Gets enabled dApps for the client.

simulateTransaction

Deprecated: Use portal.evaluateTransaction() instead.
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.ramps object

The ramps property exposes fiat on- and off-ramp integrations.

portal.ramps (Ramps)

The Ramps class groups fiat on- and off-ramp integrations. Properties See the Noah React Native SDK guide and the Meld React Native SDK guide for end-to-end flows and prerequisites.

portal.ramps.noah (Noah)

Noah methods issue HTTP requests through portal.api to /api/v3/clients/me/integrations/noah/... with the Portal client API key. Responses follow the { data, metadata? } envelope used across Client API integrations.

initiateKyc

ReturnsPromise<NoahInitiateKycResponse> with data.hostedUrl for hosted onboarding.

initiatePayin

ReturnsPromise<NoahInitiatePayinResponse> with data.payinId and structured data.bankDetails: BankDetails.

simulatePayin

ReturnsPromise<NoahSimulatePayinResponse> with data.fiatDepositId.

getPayoutCountries

ReturnsPromise<NoahGetPayoutCountriesResponse> with data.countries: Record<string, string[]>.

getPayoutChannels

ReturnsPromise<NoahGetPayoutChannelsResponse> with data.items: Channel[] and optional data.pageToken.

getPayoutChannelForm

ReturnsPromise<NoahGetPayoutChannelFormResponse> with data.formSchema and optional data.formMetadata.

getPayoutQuote

ReturnsPromise<NoahGetPayoutQuoteResponse> including payoutId, formSessionId, cryptoAmountEstimate, totalFee.

initiatePayout

ReturnsPromise<NoahInitiatePayoutResponse> with data.destinationAddress: string | null and data.conditions: DepositSourceTriggerCondition[].

getPaymentMethods

ReturnsPromise<NoahGetPaymentMethodsResponse> with data.paymentMethods: PaymentMethod[] and optional data.pageToken: string.

portal.ramps.meld (Meld)

Meld methods issue HTTP requests through portal.api to /api/v3/clients/me/integrations/meld/... with the Portal client API key. Responses follow the { data, metadata? } envelope used across Client API integrations. See the Meld React Native SDK guide for end-to-end flows with full examples.

createCustomer

ReturnsPromise<MeldCreateCustomerResponse> with data: MeldCustomer (id, externalId, accountId, name?, email?, phone?, dateOfBirth?, type?, status?, addresses?, serviceProviders?).

searchCustomer

ReturnsPromise<MeldSearchCustomerResponse> with data: { customers: MeldCustomer[]; count: number; remaining: number }.

getRetailQuote

ReturnsPromise<MeldGetRetailQuoteResponse> with data: { quotes: MeldQuote[]; message?: string; error?: string; timestamp?: string | null }. Each MeldQuote includes required fields serviceProvider, transactionType, sourceAmount, sourceCurrencyCode, destinationAmount, destinationCurrencyCode, exchangeRate, transactionFee, totalFee, paymentMethodType; and optional fields sourceAmountWithoutFees, destinationAmountWithoutFees, networkFee, partnerFee, fiatAmountWithoutFees, countryCode, customerScore, institutionName, isNativeAvailable, rampIntelligence.

createRetailWidget

ReturnsPromise<MeldCreateRetailWidgetResponse> with data: { id, token, widgetUrl, customerId, externalCustomerId, externalSessionId }.

searchRetailTransactions

ReturnsPromise<MeldSearchRetailTransactionsResponse> with data: { transactions: MeldTransaction[]; count: number; remaining: number; totalCount: number }.

getRetailTransaction

ReturnsPromise<MeldGetRetailTransactionResponse> with data: { transaction: MeldTransaction }.

getRetailTransactionBySession

ReturnsPromise<MeldGetRetailTransactionResponse> with data: { transaction: MeldTransaction }.

getServiceProviders

ReturnsPromise<MeldGetServiceProvidersResponse> with data: MeldServiceProvider[] (serviceProvider, name, status?, categories?, categoryStatuses?, websiteUrl?, customerSupportUrl?, logos? with dark?, light?, darkShort?, lightShort?).

getCountries

ReturnsPromise<MeldGetCountriesResponse> with data: MeldCountry[].

getFiatCurrencies

ReturnsPromise<MeldGetFiatCurrenciesResponse> with data: MeldFiatCurrency[].

getCryptoCurrencies

ReturnsPromise<MeldGetCryptoCurrenciesResponse> with data: MeldCryptoCurrency[].

getPaymentMethods

ReturnsPromise<MeldGetPaymentMethodsResponse> with data: MeldPaymentMethod[].

getDefaults

ReturnsPromise<MeldGetDefaultsResponse> with data: MeldCountryDefault[] (countryCode, defaultCurrencyCode, defaultPaymentMethods).

getBuyLimits

ReturnsPromise<MeldGetBuyLimitsResponse> with data: MeldFiatCurrencyPurchaseLimit[] (currencyCode, minimumAmount, maximumAmount, defaultAmount).

getSellLimits

ReturnsPromise<MeldGetSellLimitsResponse> with data: MeldCryptoCurrencySellLimit[] (currencyCode, chainCode, minimumAmount, maximumAmount, defaultAmount).

getKycLimits

ReturnsPromise<MeldGetKycLimitsResponse> with data: MeldKycFiatLevel[]. Each entry includes currencyCode and optional level1, level2, level3 of type MeldKycLimitTier with dailyLimit, weeklyLimit, monthlyLimit, yearlyLimit, transactionLimit.

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).
Parameters:

ejectPrivateKeys

Ejects both SECP256K1 and ED25519 private keys.
Parameters: Returns:

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.
Example:

React Context

PortalContextProvider

Provides the Portal instance to child components.

usePortal

Hook to access the Portal instance.

Enums

BackupMethods

PortalRequestMethod

PortalNamespace

PortalCurve

PortalSharePairStatus

MpcErrorCodes

EvaluateTransactionOperationType


Error Classes

MpcError

Custom error class for MPC operations.
Example:

Types

PortalOptions

BackupOptions

FeatureFlags

Properties:

AddressesByNamespace

GatewayConfig

gatewayConfig is optional. When omitted (or set to {}), the SDK automatically builds a default config that routes RPC traffic through Portal’s managed gateway for 10 built-in chains: Default URLs follow the pattern https://{apiHost}/rpc/v1/{namespace}/{reference} (e.g. https://api.portalhq.io/rpc/v1/eip155/1). When gatewayConfig is a non-empty object or a string, it is used exactly as supplied — the SDK does not merge defaults into a custom config. Requests to Portal’s managed gateway automatically include your apiKey as a Bearer token — no extra configuration needed. Requests to a custom RPC URL (e.g. Infura, Alchemy) are sent without it, since third-party providers require their own credentials.

Dapp

Address


Exports Summary