Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt

Use this file to discover all available pages before exploring further.

Portal Class

The Portal class is the main entry point for the Portal Web SDK. It provides methods for wallet management, transaction signing, and blockchain interactions.

Constructor

Creates a new Portal instance with the specified configuration.
constructor(options: PortalOptions)
Parameters
NameTypeRequiredDefaultDescription
options.rpcConfigRpcConfigYes-Configuration object mapping chain IDs to RPC URLs (e.g., { "eip155:1": "https://..." })
options.apiKeystringNo-Portal API key for authentication
options.authTokenstringNo-Authentication token for Portal services
options.authUrlstringNo-Custom authentication URL
options.autoApprovebooleanNofalseAutomatically approve transactions without user confirmation
options.gdriveGDriveConfigNo-Google Drive backup configuration with clientId
options.passkeyPasskeyConfigNo-Passkey configuration for WebAuthn backup
options.hoststringNo'web.portalhq.io'Portal host URL
options.mpcVersionstringNo'v6'MPC protocol version
options.mpcHoststringNo'mpc-client.portalhq.io'MPC service host
options.featureFlagsFeatureFlagsNo{}Feature flags configuration
options.chainIdstringNo-Default chain ID for the provider
options.logLevelLogLevelNo'none'Logging level: 'none', 'error', 'warn', 'info', or 'debug'. See Logging Configuration
options.loggerILoggerNoconsoleCustom logger implementing error, warn, info, and debug methods
Example Usage
import Portal from '@portal-hq/web';

const portal = new Portal({
  rpcConfig: {
    'eip155:1': 'https://...',
    'eip155:11155111': 'https://...',
    'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': 'https://...',
  },
  apiKey: 'your-api-key',
  chainId: 'eip155:1',
  gdrive: {
    clientId: 'your-client-id',
  },
});

Public Properties

PropertyTypeDescription
addressstring | undefinedThe current wallet address
apiKeystring | undefinedPortal API key
authTokenstring | undefinedAuthentication token
authUrlstring | undefinedAuthentication URL
autoApprovebooleanAuto-approve transactions setting
gDriveConfigGDriveConfig | undefinedGoogle Drive configuration
passkeyConfigPasskeyConfig | undefinedPasskey configuration
hoststringPortal host URL
mpcMpcMPC instance for wallet operations
yieldYieldYield.xyz integration instance
tradingTradingLiFi trading integration instance
rampsRampsNoah virtual accounts and payouts namespace (portal.ramps.noah)
delegationsDelegationsToken delegations (portal.delegations)
mpcHoststringMPC service host
mpcVersionstringMPC protocol version
providerProviderProvider instance for RPC requests
featureFlagsFeatureFlagsFeature flags configuration
readybooleanWhether the Portal instance is ready (read-only getter)

Feature flags

The featureFlags option controls optional SDK behavior. Pass it when creating a Portal instance.
PropertyTypeDefaultDescription
usePresignaturesbooleanfalseWhen true, the SDK uses presignatures to improve signing latency. The SDK generates and consumes presignatures in the background; you do not call presign APIs directly. Applies to SECP256K1 (EVM) signing only. See Feature flags for details.
Example
const portal = new Portal({
  rpcConfig: { 'eip155:1': 'https://...' },
  apiKey: 'your-api-key',
  featureFlags: {
    usePresignatures: true,
  },
})

Logging Methods

setLogLevel

Sets the SDK log level at runtime. All SDK messages (e.g. deprecation warnings, provider messages) respect this level.
public setLogLevel(level: LogLevel): void
Parameters
NameTypeDescription
levelLogLevelOne of 'none', 'error', 'warn', 'info', or 'debug'
Example Usage
portal.setLogLevel('debug')  // Enable verbose logging
portal.setLogLevel('none')   // Disable all SDK logs
See Logging Configuration for full details.

getLogLevel

Returns the current SDK log level.
public getLogLevel(): LogLevel
Returns LogLevel — The current level: 'none' | 'error' | 'warn' | 'info' | 'debug' Example Usage
const level = portal.getLogLevel()
console.log('Current log level:', level)

Initialization Methods

onReady

Registers a callback to be executed when the Portal instance is ready.
public onReady(callback: () => any | Promise<any>): () => void
Parameters
NameTypeDescription
callback() => any | Promise<any>Function to execute when ready
Returns A cleanup function that removes the callback when called. Example Usage
const unsubscribe = portal.onReady(() => {
  console.log('Portal is ready!');
});

// Later, to remove the callback:
unsubscribe();

onInitializationError

Registers a callback to be executed if initialization fails.
public onInitializationError(callback: (reason: string) => any | Promise<any>): () => void
Parameters
NameTypeDescription
callback(reason: string) => any | Promise<any>Function to execute on error, receives error reason
Returns A cleanup function that removes the callback when called. Example Usage
const unsubscribe = portal.onInitializationError(reason => {
  console.error('Initialization failed:', reason);
});

Wallet Lifecycle Methods

createWallet

Creates a new wallet and generates addresses for supported chains.
public async createWallet(progress?: ProgressCallback): Promise<string>
Parameters
NameTypeDescription
progressProgressCallbackOptional callback for tracking progress with MpcStatus updates
Returns Promise<string> - The wallet address Example Usage
const address = await portal.createWallet(status => {
  console.log('Status:', status);
});

console.log('Wallet created with address:', address);

backupWallet

Creates a backup of the wallet using the specified backup method.
public async backupWallet(
  backupMethod: BackupMethods,
  progress?: ProgressCallback,
  backupConfigs?: BackupConfigs
): Promise<BackupResponse>
Parameters
NameTypeDescription
backupMethodBackupMethodsBackup method: GDRIVE, PASSWORD, or PASSKEY
progressProgressCallbackOptional progress callback
backupConfigsBackupConfigsOptional backup configuration (e.g., password)
Returns Promise<BackupResponse> containing:
  • cipherText: Encrypted backup data
  • storageCallback: Function to finalize storage
Example Usage
// Password backup
const backup = await portal.backupWallet(BackupMethods.password, status => console.log(status), {
  passwordStorage: { password: 'your-password' },
});

// Complete the backup storage
await backup.storageCallback();
console.log('Backup cipher text:', backup.cipherText);

recoverWallet

Recovers a wallet from a backup.
public async recoverWallet(
  cipherText: string,
  backupMethod: BackupMethods,
  backupConfigs?: BackupConfigs,
  progress?: ProgressCallback
): Promise<string>
Parameters
NameTypeDescription
cipherTextstringEncrypted backup data
backupMethodBackupMethodsBackup method used
backupConfigsBackupConfigsOptional backup configuration
progressProgressCallbackOptional progress callback
Returns Promise<string> - The recovered wallet address Example Usage
const address = await portal.recoverWallet('your-cipher-text', BackupMethods.password, {
  passwordStorage: { password: 'your-password' },
});

console.log('Wallet recovered:', address);

provisionWallet

Alias for recoverWallet. Provisions a wallet from a backup.
public async provisionWallet(
  cipherText: string,
  backupMethod: BackupMethods,
  backupConfigs: BackupConfigs,
  progress?: ProgressCallback
): Promise<string>

clearLocalWallet

Clears the local wallet data from device storage.
public async clearLocalWallet(): Promise<boolean>
Returns Promise<boolean> - true if successful Example Usage
const cleared = await portal.clearLocalWallet();
console.log('Wallet cleared:', cleared);

Wallet Status Methods

doesWalletExist

Checks if a wallet exists for the client.
public async doesWalletExist(chainId?: string): Promise<boolean>
Parameters
NameTypeDescription
chainIdstringOptional chain ID to check specific namespace (e.g., 'eip155:1')
Returns Promise<boolean> - true if wallet exists Example Usage
// Check if any wallet exists
const exists = await portal.doesWalletExist();

// Check for specific chain
const hasEthWallet = await portal.doesWalletExist('eip155:1');

isWalletOnDevice

Checks if wallet shares are stored on the current device.
public async isWalletOnDevice(chainId?: string): Promise<boolean>
Parameters
NameTypeDescription
chainIdstringOptional chain ID to check specific curve
Returns Promise<boolean> - true if wallet is on device

isWalletBackedUp

Checks if the wallet has been backed up.
public async isWalletBackedUp(chainId?: string): Promise<boolean>
Parameters
NameTypeDescription
chainIdstringOptional chain ID to check specific wallet
Returns Promise<boolean> - true if wallet is backed up

isWalletRecoverable

Checks if the wallet can be recovered.
public async isWalletRecoverable(chainId?: string): Promise<boolean>
Returns Promise<boolean> - true if wallet is recoverable

availableRecoveryMethods

Gets the available recovery methods for the wallet.
public async availableRecoveryMethods(chainId?: string): Promise<BackupMethods[]>
Returns Promise<BackupMethods[]> - Array of available backup methods Example Usage
const methods = await portal.availableRecoveryMethods();
console.log('Available recovery methods:', methods);
// e.g., ['GDRIVE', 'PASSWORD']

Address Methods

getEip155Address

Gets the EIP-155 (Ethereum-compatible) address.
public async getEip155Address(): Promise<string>
Returns Promise<string> - The Ethereum address Example Usage
const ethAddress = await portal.getEip155Address();
console.log('Ethereum address:', ethAddress);

getSolanaAddress

Gets the Solana address.
public async getSolanaAddress(): Promise<string>
Returns Promise<string> - The Solana address Example Usage
const solAddress = await portal.getSolanaAddress();
console.log('Solana address:', solAddress);

Eject Methods

Providing the custodian backup share to the client device puts both MPC shares on a single device, removing the multi-party security benefits of MPC. This operation should only be done for users who want to move off of MPC and into a single private key. Use portal.eject() or portal.ejectPrivateKeys() at your own risk!

eject

Ejects the SECP256K1 private key from MPC custody. For eject examples see here
public async eject(
  backupMethod: BackupMethods,
  backupConfigs: BackupConfigs,
  orgBackupShare?: string,
  clientBackupCipherText?: string
): Promise<EjectResult>
Parameters
NameTypeDescription
backupMethodBackupMethodsBackup method to use
backupConfigsBackupConfigsBackup configuration
orgBackupSharestringOrganization backup share (required if not using Portal backup)
clientBackupCipherTextstringClient backup cipher text (required if not using Portal backup)
Returns Promise<EjectResult> containing:
  • SECP256K1: The private key as a string

ejectPrivateKeys

Ejects all private keys (both SECP256K1 and ED25519) from MPC custody.
public async ejectPrivateKeys(
  backupMethod: BackupMethods,
  backupConfigs: BackupConfigs,
  orgBackupShares: OrgBackupShares,
  clientBackupCipherText?: string
): Promise<EjectPrivateKeysResult>
Parameters
NameTypeDescription
backupMethodBackupMethodsBackup method to use
backupConfigsBackupConfigsBackup configuration
orgBackupSharesOrgBackupSharesOrganization backup shares for both curves
clientBackupCipherTextstringClient backup cipher text (required if not using Portal backup)
Returns Promise<EjectPrivateKeysResult> containing:
  • SECP256K1: The SECP256K1 private key
  • ED25519: The ED25519 private key

Transaction Methods

request

Makes an RPC request to a blockchain network. This is the primary method for interacting with blockchains.
public async request(request: RequestArguments): Promise<any>
Parameters
NameTypeDescription
request.chainIdstringChain ID in CAIP-2 format (e.g., 'eip155:1')
request.methodstringRPC method name (e.g., 'eth_sendTransaction')
request.paramsanyMethod parameters
request.sponsorGasbooleanOptional. Whether to sponsor gas (Account Abstraction).
request.signatureApprovalMemostringOptional. Memo shown to the user during the signature approval flow.
Returns Promise<any> - Response from the RPC call Example Usage
// Send Ethereum transaction
const txHash = await portal.request({
  chainId: 'eip155:1',
  method: 'eth_sendTransaction',
  params: [
    {
      from: portal.address,
      to: '0x...',
      value: '0xDE0B6B3A7640000', // 1 ETH in wei
    },
  ],
  signatureApprovalMemo: 'Send 1 ETH', // optional
});

// Sign Solana transaction
const signature = await portal.request({
  chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
  method: 'sol_signAndSendTransaction',
  params: [transaction],
});

sendAsset

Helper method to send assets to another address.
public async sendAsset(chain: string, params: SendAssetParams): Promise<SendAssetResponse>
Parameters
NameTypeDescription
chainstringChain ID or friendly name (e.g., 'ethereum', 'solana')
params.tostringRecipient address
params.tokenstringToken contract address or native token identifier
params.amountstringAmount to send
params.sponsorGasbooleanOptional. Whether to sponsor gas (Account Abstraction).
params.signatureApprovalMemostringOptional. Memo shown to the user during the signature approval flow.
Returns Promise<SendAssetResponse> containing transaction hash and metadata Example Usage
const result = await portal.sendAsset('ethereum', {
  to: '0x...',
  token: '0x0000000000000000000000000000000000000000', // Native ETH
  amount: '1000000000000000000', // 1 ETH in wei
});

console.log('Transaction hash:', result.transactionHash);

sendSol

Helper method to send SOL tokens.
public async sendSol({
  chainId,
  to,
  lamports
}: {
  chainId: string
  to: string
  lamports: number
}): Promise<string>
Parameters
NameTypeDescription
chainIdstringSolana chain ID (must start with 'solana:')
tostringRecipient Solana address (44 characters)
lamportsnumberAmount in lamports (1 SOL = 1,000,000,000 lamports)
Returns Promise<string> - Transaction signature Example Usage
const signature = await portal.sendSol({
  chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
  to: 'DYw8...',
  lamports: 1000000000, // 1 SOL
});

sendEth

Helper method to send ETH.
public sendEth = async ({
  chainId,
  to,
  value
}: {
  chainId: string
  to: string
  value: string
}): Promise<any>
Parameters
NameTypeDescription
chainIdstringEIP-155 chain ID
tostringRecipient address
valuestringAmount in wei (hex string)
Returns Promise<any> - Transaction hash Example Usage
const txHash = await portal.sendEth({
  chainId: 'eip155:1',
  to: '0x...',
  value: '0xDE0B6B3A7640000', // 1 ETH in wei
});

console.log('Transaction hash:', txHash);

rawSign

Signs data directly using the specified cryptographic curve. An optional third argument accepts signatureApprovalMemo which is shown to the user during the approval flow.
public async rawSign(
  curve: PortalCurve,
  param: string,
  options?: RawSignOptions
): Promise<string>
Parameters
NameTypeDescription
curvePortalCurveCryptographic curve (ED25519 or SECP256K1)
paramstringData to sign
optionsRawSignOptionsOptional. { signatureApprovalMemo?: string }
Returns Promise<string> - Signature Example Usage
import { PortalCurve } from '@portal-hq/web';

// Sign with SECP256K1 (Ethereum)
const signature = await portal.rawSign(PortalCurve.SECP256K1, 'your-data-to-sign');

// With optional approval memo (shown to user during approval)
const signatureWithMemo = await portal.rawSign(
  PortalCurve.SECP256K1,
  'your-data-to-sign',
  { signatureApprovalMemo: 'Sign login challenge' }
);

console.log('Signature:', signature);

Delegations

portal.delegations exposes approve, revoke, status, transfer, and high-level sign-and-submit helpers for token delegations on supported EVM and Solana chains. See Manage Token Delegations for walkthroughs. The interfaces below match the types exported from @portal-hq/web (for example import type { ApproveDelegationRequest } from '@portal-hq/web').

portal.delegations methods

MethodSignature
approveapprove(params: ApproveDelegationRequest): Promise<ApproveDelegationResponse>
revokerevoke(params: RevokeDelegationRequest): Promise<RevokeDelegationResponse>
getStatusgetStatus(params: GetDelegationStatusRequest): Promise<DelegationStatusResponse>
transferFromtransferFrom(params: TransferFromRequest): Promise<TransferFromResponse>
approveAndSubmitapproveAndSubmit(params: ApproveDelegationRequest, options?: DelegationSubmitOptions): Promise<{ hashes: string[] }>
revokeAndSubmitrevokeAndSubmit(params: RevokeDelegationRequest, options?: DelegationSubmitOptions): Promise<{ hashes: string[] }>
transferAndSubmittransferAndSubmit(params: TransferFromRequest, options?: DelegationSubmitOptions): Promise<{ hashes: string[] }>

Request and options types

ApproveDelegationRequest

interface ApproveDelegationRequest {
  chain: string
  token: string
  delegateAddress: string
  amount: string
}

RevokeDelegationRequest

interface RevokeDelegationRequest {
  chain: string
  token: string
  delegateAddress: string
}

GetDelegationStatusRequest

interface GetDelegationStatusRequest {
  chain: string
  token: string
  delegateAddress: string
}

TransferFromRequest

interface TransferFromRequest {
  chain: string
  token: string
  fromAddress: string
  toAddress: string
  amount: string
}

DelegationSubmitOptions

Optional second argument for approveAndSubmit, revokeAndSubmit, and transferAndSubmit.
interface DelegationSubmitOptions {
  signAndSendTransaction?: (
    transaction: unknown,
    chainId: string
  ) => Promise<string>
  onProgress?: (event: DelegationSubmitProgress) => void
}

DelegationSubmitProgress

interface DelegationSubmitProgress {
  step: 'signing' | 'submitted'
  index: number
  total: number
  hash?: string
}

Yield Types

Types used by the high-level deposit and withdraw methods on portal.yield.yieldXyz. All types are exported from @portal-hq/web.

YieldDepositParams

Union type — provide either yieldId or chain + token. A non-empty yieldId takes precedence.
type YieldDepositParams =
  | { yieldId: string; amount: string; address?: string; arguments?: YieldXyzEnterArguments }
  | { chain: string; token: string; amount: string; address?: string; arguments?: YieldXyzEnterArguments }

YieldWithdrawParams

Same union as YieldDepositParams.
type YieldWithdrawParams = YieldDepositParams

YieldSubmitOptions

interface YieldSubmitOptions {
  onProgress?: (event: YieldSubmitProgress) => void
  signAndSendTransaction?: (transaction: unknown, network: string) => Promise<string>
  waitForConfirmation?: (txHash: string, network: string) => Promise<void | boolean>
  evmRequestFn?: (method: string, params: unknown[], network: string) => Promise<unknown>
  evmPollerOptions?: { pollIntervalMs?: number; timeoutMs?: number }
}

YieldSubmitProgress

interface YieldSubmitProgress {
  step: 'signing' | 'submitted' | 'confirming' | 'confirmed'
  index: number
  total: number
  hash?: string
}

YieldDepositResult

interface YieldDepositResult {
  hashes: string[]
  yieldId: string
  chain?: string
  token?: string
  yieldOpportunityDetails: {
    yieldId: string
    intent?: string
    type?: string
    executionPattern?: string
    status?: string
    amount?: string | null
    amountUsd?: string | null
  }
}

YieldWithdrawResult

Same shape as YieldDepositResult.
interface YieldWithdrawResult {
  hashes: string[]
  yieldId: string
  chain?: string
  token?: string
  yieldOpportunityDetails: {
    yieldId: string
    intent?: string
    type?: string
    executionPattern?: string
    status?: string
    amount?: string | null
    amountUsd?: string | null
  }
}

YieldXyzValidator

interface YieldXyzValidator {
  address: string
  name?: string
  commission?: string
  apy?: string
  [key: string]: unknown
}

API Methods

getClient

Gets information about the client and their wallets.
public async getClient(): Promise<ClientResponse>
Returns Promise<ClientResponse> with client information including:
  • id: Client ID
  • address: Primary address
  • wallets: Array of wallet information
  • metadata: Namespace metadata with addresses
Example Usage
const client = await portal.getClient();
console.log('Client ID:', client.id);
console.log('Wallets:', client.wallets);

getAssets

Gets the assets (tokens) held by the wallet.
public async getAssets(chainId: string, includeNfts?: boolean): Promise<GetAssetsResponse>
Parameters
NameTypeDescription
chainIdstringChain ID to query
includeNftsbooleanWhether to include NFTs (default: false)
Returns Promise<GetAssetsResponse> with asset information Example Usage
const assets = await portal.getAssets('eip155:1', false);
console.log('Assets:', assets);

getNFTAssets

Gets NFT assets held by the wallet.
public async getNFTAssets(chainId: string): Promise<NFTAsset[]>
Parameters
NameTypeDescription
chainIdstringChain ID to query
Returns Promise<NFTAsset[]> - Array of NFT assets Example Usage
const nfts = await portal.getNFTAssets('eip155:1');
console.log('NFT assets:', nfts);

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.
public async getTransactionHistory(
  params: GetTransactionHistoryParams
): Promise<GetTransactionHistoryResponse>
Parameters
NameTypeDescription
params.chainIdstringChain ID in CAIP-2 format (e.g., 'eip155:1', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
params.limitnumberMaximum number of transactions to return (default: 50; max: 1000 for EVM, 15 for Solana)
params.offsetnumberNumber of transactions to skip for pagination (default: 0)
params.order'asc' | 'desc'Sort order by block number (default: 'desc', EVM only)
params.addressstringOptional address override (EVM only)
params.userOperations'include' | 'only' | 'exclude'Optional. Filter ERC-4337 UserOperations on EVM chains (eip155:*) only. If set, the SDK always sends that value unchanged.
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:*):
{
  data: {
    transactions: SolanaTransactionDetails[]
  },
  metadata: {
    address: string
    chainId: string
    clientId: string
    limit: number
    offset: number
    count: number
  }
}
For EVM, Bitcoin, Tron, Stellar chains:
{
  data: {
    transactions: TransactionHistoryItem[]
  },
  metadata: {
    address: string
    chainId: string
    clientId: string
    limit: number
    offset: number
    count: number
  }
}
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
// Get EVM transactions including UserOperations
const evmTxs = await portal.getTransactionHistory({
  chainId: 'eip155:1',
  limit: 20,
  order: 'desc',
  userOperations: 'include',  // Include both regular txs and UserOps
});

// Type narrowing based on transaction type
evmTxs.data.transactions.forEach(tx => {
  if (tx.type === 'userOperation') {
    console.log('UserOp hash:', tx.userOpHash);
    console.log('Entry point:', tx.entryPoint);
    // tx.asset not available (compile error)
  } else {
    console.log('Token:', tx.asset);
    console.log('Token address:', tx.tokenAddress);
    // tx.userOpHash not available (compile error)
  }
});

// EVM + Account Abstraction: omit `userOperations`
// If wallet is AA-enabled, SDK injects `userOperations='only'`
// Otherwise (EOA), the parameter is not sent
const aaEvmHistory = await portal.getTransactionHistory({
  chainId: 'eip155:42161',
  limit: 20,
});

// Get Solana transactions
const solanaTxs = await portal.getTransactionHistory({
  chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
  limit: 15,
});

// Solana transactions have a different structure
solanaTxs.data.transactions.forEach(tx => {
  console.log('Signature:', tx.signature);
  console.log('Block time:', tx.blockTime);
  console.log('Status:', tx.status);
});

// Get only UserOperations (EVM only)
const userOps = await portal.getTransactionHistory({
  chainId: 'eip155:137',
  userOperations: 'only',
  limit: 10,
});

getTransactions

Deprecated: Use 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.
Gets transaction history for the wallet.
public async getTransactions(
  chainId: string,
  limit?: number,
  offset?: number,
  order?: GetTransactionsOrder
): Promise<Transaction[]>
Parameters
NameTypeDescription
chainIdstringChain ID to query
limitnumberMaximum number of transactions to return
offsetnumberNumber of transactions to skip
orderGetTransactionsOrderSort order: 'asc' or 'desc'
Returns Promise<Transaction[]> - Array of transactions Example Usage
import { GetTransactionsOrder } from '@portal-hq/web';

// ⚠️ DEPRECATED: Use getTransactionHistory() instead
const txs = await portal.getTransactions('eip155:1', 10, 0, GetTransactionsOrder.DESC);

// ✅ RECOMMENDED: Use the new method with improved type safety
const walletTxs = await portal.getTransactionHistory({
  chainId: 'eip155:1',
  limit: 10,
  offset: 0,
  order: 'desc',
});

evaluateTransaction

Evaluates a transaction before execution to check if the transaction can be executed, and perform security validations.
public async evaluateTransaction(
  chainId: string,
  transaction: EvaluateTransactionParam,
  operationType?: EvaluateTransactionOperationType
): Promise<EvaluatedTransaction>
Parameters
NameTypeDescription
chainIdstringChain ID
transactionEvaluateTransactionParamTransaction to evaluate
operationTypeEvaluateTransactionOperationTypeType of evaluation (default: 'all')
Returns Promise<EvaluatedTransaction> with security analysis Example Usage
const evaluation = await portal.evaluateTransaction('eip155:1', {
  from: portal.address,
  to: '0x...',
  value: '0x1',
});

console.log('Security warnings:', evaluation.warnings);

buildTransaction

Builds a transaction for sending tokens.
public async buildTransaction(
  chainId: string,
  to: string,
  token: string,
  amount: string
): Promise<BuiltTransaction>
Parameters
NameTypeDescription
chainIdstringChain ID
tostringRecipient address
tokenstringToken contract address
amountstringAmount to send
Returns Promise<BuiltTransaction> with the built transaction object Example Usage
const builtTx = await portal.buildTransaction(
  'eip155:1',
  '0x...',
  '0x0000000000000000000000000000000000000000', // Native ETH
  '1000000000000000000' // 1 ETH in wei
);

// Use the built transaction
const txHash = await portal.request({
  chainId: 'eip155:1',
  method: 'eth_sendTransaction',
  params: [builtTx.transaction],
});

receiveTestnetAsset

Requests testnet assets from a faucet.
public async receiveTestnetAsset(chainId: string, params: FundParams): Promise<FundResponse>
Parameters
NameTypeDescription
chainIdstringTestnet chain ID
params.amountstringAmount to request
params.tokenstringToken identifier
Returns Promise<FundResponse> with funding details Example Usage
const fundResponse = await portal.receiveTestnetAsset('eip155:11155111', {
  amount: '1',
  token: 'ETH',
});

console.log('Transaction hash:', fundResponse.data?.txHash);
console.log('Explorer URL:', fundResponse.data?.explorerUrl);

Swap Methods

getQuote

Gets a quote for an in-chain token swap.
Deprecated: Use the portal.trading.zerox.getQuote method instead.
public async getQuote(
  apiKey: string,
  args: QuoteArgs,
  chainId: string
): Promise<QuoteResponse>

getSources

Gets available swap sources for in-chain swaps.
Deprecated: Use the portal.trading.zerox.getSources method instead.
public async getSources(apiKey: string, chainId: string): Promise<Record<string, string>>

Utility Methods

updateChain

Updates the current chain ID for the provider.
public updateChain(newChainId: string): void
Parameters
NameTypeDescription
newChainIdstringNew chain ID to set
Example Usage
portal.updateChain('eip155:137'); // Switch to Polygon

getRpcUrl

Gets the configured RPC URL for a chain.
public getRpcUrl(chainId?: string): string
Parameters
NameTypeDescription
chainIdstringChain ID to look up
Returns string - The RPC URL Throws Error if chain ID is not configured

storedClientBackupShare

Notifies Portal that a backup share has been stored.
public async storedClientBackupShare(success: boolean, backupMethod: BackupMethods): Promise<void>
Parameters
NameTypeDescription
successbooleanWhether the backup was successful
backupMethodBackupMethodsThe backup method that was used
Returns Promise<void> Example Usage
import { BackupMethods } from '@portal-hq/web';

// After successfully storing a backup
await portal.storedClientBackupShare(true, BackupMethods.gdrive);

Integration Classes

portal.yield (Yield)

The Yield class provides access to Yield.xyz integration for yield farming opportunities. Properties
PropertyTypeDescription
yieldXyzYieldXyzYield.xyz integration instance

getValidators

Fetches validator addresses for a specific yieldId. Delegates to portal.yield.yieldXyz.getValidators. Throws if the response does not contain a valid validators array.
public getValidators(yieldId: string): Promise<YieldXyzValidator[]>
Parameters
NameTypeDescription
yieldIdstringYield opportunity identifier (e.g. monad-testnet-mon-native-staking)
Returns Promise<YieldXyzValidator[]> — Array of validator objects. Each entry includes at minimum address: string plus optional name, commission, apy, and any additional provider-specific fields. Example Usage
const validators = await portal.yield.getValidators('monad-testnet-mon-native-staking')
console.log('Validators:', validators)

portal.yield.yieldXyz (YieldXyz)

Access yield farming features through the Yield.xyz integration. Includes low-level methods (discover, enter, exit, manage, track, getTransaction, getBalances, getHistoricalActions) and high-level helpers (deposit, withdraw). See the Yield.xyz guide for walkthroughs.

deposit

High-level deposit: resolves the yield, builds the enter action, signs and sends each transaction in order, waits for confirmation between steps when configured, and reports hashes to Yield.xyz — all in one call. See the Yield.xyz guide for parameter tables and examples.
public async deposit(
  params: YieldDepositParams,
  options?: YieldSubmitOptions,
): Promise<YieldDepositResult>
Parameters
NameTypeRequiredDescription
paramsYieldDepositParamsYesEither { yieldId, amount } or { chain, token, amount }. Non-empty yieldId takes precedence. chain must be a full CAIP-2 id (e.g. eip155:11155111). Optional address and arguments.
optionsYieldSubmitOptionsNoonProgress, per-call signAndSendTransaction, waitForConfirmation, evmRequestFn, evmPollerOptions.
Returns Promise<YieldDepositResult> with fields:
FieldTypeDescription
hashesstring[]Submitted tx hashes, in order.
yieldIdstringResolved yield id.
chainstring?Echoed when you passed chain + token.
tokenstring?Echoed when you passed chain + token.
yieldOpportunityDetailsobjectAction metadata from Yield.xyz (yieldId, intent, type, executionPattern, status, amount, amountUsd).

withdraw

High-level withdraw: same dual-input modes, yieldId resolution, signer fallback, and confirmation behavior as deposit, but calls the Yield.xyz exit action. See the Yield.xyz guide for parameter tables and examples.
public async withdraw(
  params: YieldWithdrawParams,
  options?: YieldSubmitOptions,
): Promise<YieldWithdrawResult>
Parameters
NameTypeRequiredDescription
paramsYieldWithdrawParamsYesSame union as YieldDepositParams.
optionsYieldSubmitOptionsNoSame options as deposit.
Returns Promise<YieldWithdrawResult> — Same shape as YieldDepositResult.

discover

Discovers available yield opportunities.
public async discover(data: YieldXyzGetYieldsRequest): Promise<YieldXyzGetYieldsResponse>
Parameters
NameTypeDescription
dataYieldXyzGetYieldsRequestParameters for yield discovery
Returns Promise<YieldXyzGetYieldsResponse> - Available yield opportunities Example Usage
const yields = await portal.yield.yieldXyz.discover({
  // Discovery parameters
});
console.log('Available yields:', yields);

getBalances

Retrieves yield balances for specified addresses and networks.
public async getBalances(data: YieldXyzGetBalancesRequest): Promise<YieldXyzGetBalancesResponse>
Parameters
NameTypeDescription
dataYieldXyzGetBalancesRequestRequest parameters including addresses and networks
Returns Promise<YieldXyzGetBalancesResponse> - Balance information

getHistoricalActions

Retrieves historical yield actions with optional filtering.
public async getHistoricalActions(
  data: YieldXyzGetHistoricalActionsRequest
): Promise<YieldXyzGetHistoricalActionsResponse>
Returns Promise<YieldXyzGetHistoricalActionsResponse> - Historical actions

enter

Enters a yield opportunity.
public async enter(data: YieldXyzEnterRequest): Promise<YieldXyzEnterYieldResponse>
Parameters
NameTypeDescription
dataYieldXyzEnterRequestParameters for entering a yield opportunity
Returns Promise<YieldXyzEnterYieldResponse> - Action details Example Usage
const result = await portal.yield.yieldXyz.enter({
  // Enter parameters
});

exit

Exits a yield opportunity.
public async exit(data: YieldXyzExitRequest): Promise<YieldXyzExitResponse>
Parameters
NameTypeDescription
dataYieldXyzExitRequestParameters for exiting a yield opportunity
Returns Promise<YieldXyzExitResponse> - Action details

manage

Manages a yield opportunity with specified parameters.
public async manage(data: YieldXyzManageYieldRequest): Promise<YieldXyzManageYieldResponse>
Parameters
NameTypeDescription
dataYieldXyzManageYieldRequestParameters for managing a yield opportunity
Returns Promise<YieldXyzManageYieldResponse> - Action details

track

Tracks a transaction by submitting its hash.
public async track(data: YieldXyzTrackTransactionRequest): Promise<YieldXyzTrackTransactionResponse>
Parameters
NameTypeDescription
data.transactionIdstringThe ID of the transaction to track
data.txHashstringThe hash of the transaction to submit
Returns Promise<YieldXyzTrackTransactionResponse> - Tracking confirmation

getTransaction

Retrieves a single yield action transaction by its ID.
public async getTransaction(transactionId: string): Promise<YieldXyzGetTransactionResponse>
Parameters
NameTypeDescription
transactionIdstringThe transaction ID to retrieve
Returns Promise<YieldXyzGetTransactionResponse> - Transaction details

portal.trading (Trading)

The Trading class provides access to:
  • Li.Fi integration for cross-chain swaps and bridges
  • 0x integration for in-chain swaps
Properties
PropertyTypeDescription
lifiLiFiLi.Fi integration instance
zeroXZeroX0x integration instance

portal.trading.lifi (LiFi)

Access cross-chain swap and bridge features through the Li.Fi integration. Includes tradeAsset for end-to-end trades and lower-level methods for manual flows. See the Li.Fi guide for walkthroughs.

tradeAsset

Runs the end-to-end Li.Fi flow in one call: discover routes, select a route, build each step, sign and broadcast, wait for confirmation, poll Li.Fi status for cross-chain steps, and return hashes. See the Li.Fi guide for parameter tables, progress lifecycle, and examples.
public async tradeAsset(
  params: LifiTradeAssetParams,
  options?: LifiTradeAssetOptions,
): Promise<LifiTradeAssetResult>
Parameters
NameTypeRequiredDescription
paramsLifiTradeAssetParamsYesfromChain, toChain, fromToken, toToken, amount, fromAddress (required); toAddress, routeOptions, routeIndex, onProgress, statusPoll (optional).
optionsLifiTradeAssetOptionsNoPer-call signAndSendTransaction, waitForConfirmation, evmRequestFn, evmPollerOptions.
Returns Promise<LifiTradeAssetResult> with fields:
FieldTypeDescription
hashesstring[]Transaction hashes per executed step.
stepsLifiStep[]Step objects from the API.
routeLifiRouteThe executed route.

pollStatus

Built-in Li.Fi status polling with retries and exponential backoff. Use when you already have a tx hash and want the same polling behavior as inside tradeAsset. See the Li.Fi guide for option defaults and examples.
public async pollStatus(
  request: Pick<LifiStatusRequest, 'txHash' | 'fromChain' | 'toChain' | 'bridge'>,
  options?: LifiPollStatusOptions & {
    onUpdate?: (raw: LifiStatusRawResponse) => boolean | void
  },
): Promise<LifiStatusRawResponse>
Parameters
NameTypeRequiredDescription
request.txHashstringYesTransaction hash to poll.
request.fromChainstringYesSource chain.
request.toChainstringNoDestination chain.
request.bridgestringNoBridge tool identifier.
options.everyMsnumberNoInterval between requests (default 10000).
options.initialDelayMsnumberNoDelay before the first request (default 10000).
options.timeoutMsnumberNoMax total poll time (default 600000).
options.maxConsecutiveErrorsnumberNoAbort after this many consecutive errors (default 10).
options.backoff{ factor: number; maxIntervalMs: number }NoBackoff config (default factor: 1.5, maxIntervalMs: 15000).
options.onUpdate(raw: LifiStatusRawResponse) => boolean | voidNoReturn false to stop early.
Returns Promise<LifiStatusRawResponse> — Terminal status response.

getRoutes

Retrieves available routes for cross-chain swaps and bridges.
public async getRoutes(data: LifiRoutesRequest): Promise<LifiRoutesResponse>
Parameters
NameTypeDescription
dataLifiRoutesRequestParameters for route discovery
Returns Promise<LifiRoutesResponse> - Available routes Example Usage
const routes = await portal.trading.lifi.getRoutes({
  fromChainId: 1,
  toChainId: 137,
  fromTokenAddress: '0x...',
  toTokenAddress: '0x...',
  fromAmount: '1000000000000000000',
});
console.log('Available routes:', routes);

getQuote

Retrieves a quote for a swap or bridge operation.
public async getQuote(data: LifiQuoteRequest): Promise<LifiQuoteResponse>
Parameters
NameTypeDescription
dataLifiQuoteRequestParameters for the quote request
Returns Promise<LifiQuoteResponse> - Quote details including fees and estimated time Example Usage
const quote = await portal.trading.lifi.getQuote({
  fromChain: '1',
  toChain: '137',
  fromToken: '0x...',
  toToken: '0x...',
  fromAmount: '1000000000000000000',
  fromAddress: portal.address,
});

getStatus

Retrieves the status of a cross-chain transaction.
public async getStatus(data: LifiStatusRequest): Promise<LifiStatusResponse>
Parameters
NameTypeDescription
dataLifiStatusRequestStatus request parameters including transaction hash
Returns Promise<LifiStatusResponse> - Transaction status Example Usage
const status = await portal.trading.lifi.getStatus({
  txHash: '0x...',
  bridge: 'hop',
});
console.log('Transaction status:', status.status);

getRouteStep

Retrieves an unsigned transaction for a specific route step.
public async getRouteStep(data: LifiStepTransactionRequest): Promise<LifiStepTransactionResponse>
Parameters
NameTypeDescription
dataLifiStepTransactionRequestStep transaction request with step details
Returns Promise<LifiStepTransactionResponse> - Unsigned transaction ready to be signed Example Usage
const step = await portal.trading.lifi.getRouteStep({
  route: selectedRoute,
  stepIndex: 0,
});

// Sign and send the transaction
const txHash = await portal.request({
  chainId: 'eip155:1',
  method: 'eth_sendTransaction',
  params: [step.transactionRequest],
});

portal.trading.zeroX (0x)

Access in-chain swap features through the 0x integration. See the 0x guide for full walkthroughs.

tradeAsset

Fetches a 0x quote, signs and broadcasts the transaction, waits for on-chain confirmation, and returns hashes. See the 0x guide for parameter tables and examples.
public async tradeAsset(
  params: ZeroXTradeAssetParams,
  options?: ZeroXTradeAssetOptions,
): Promise<ZeroXTradeAssetResult>

getPrice

Retrieves an indicative price for a token swap without generating executable transaction data.
public async getPrice(
  request: ZeroExPriceRequest,
  options?: { zeroXApiKey?: string },
): Promise<ZeroExPriceResponse>

getQuote

Gets a swap quote with executable transaction data.
public async getQuote(
  request: ZeroExQuoteRequest,
  options?: { zeroXApiKey?: string },
): Promise<ZeroExQuoteResponse>

getSources

Gets available liquidity sources for a chain.
public async getSources(
  chainId: string,
  options?: { zeroXApiKey?: string },
): Promise<ZeroExSourcesResponse>

portal.ramps (Ramps)

The Ramps class groups virtual account and payout integrations. Today it exposes Noah only. Properties
PropertyTypeDescription
noahNoahNoah ramp API
See the Noah Web SDK guide for end-to-end flows, prerequisites, and Noah Business API / EMM references.

portal.ramps.noah (Noah)

Noah methods forward to the embedded Portal iframe, which calls https://api.portalhq.io/api/v3/clients/me/integrations/noah/... with the authenticated client session. Responses follow the { data, metadata? } envelope used across Client API integrations.

initiateKyc

public async initiateKyc(data: NoahInitiateKycRequest): Promise<NoahInitiateKycResponse>
ParameterTypeDescription
dataNoahInitiateKycRequestreturnUrl (HTTPS), optional fiatOptions, customerType, metadata, form
ReturnsPromise<NoahInitiateKycResponse> with data.hostedUrl for hosted onboarding.

initiatePayin

public async initiatePayin(data: NoahInitiatePayinRequest): Promise<NoahInitiatePayinResponse>
ParameterTypeDescription
dataNoahInitiatePayinRequestfiatCurrency, cryptoCurrency, CAIP-2 network, destinationAddress
ReturnsPromise<NoahInitiatePayinResponse> with data.payinId and data.bankDetails.

simulatePayin

public async simulatePayin(data: NoahSimulatePayinRequest): Promise<NoahSimulatePayinResponse>
ParameterTypeDescription
dataNoahSimulatePayinRequestpaymentMethodId, fiatAmount, fiatCurrency
ReturnsPromise<NoahSimulatePayinResponse> (sandbox simulation payload).

getPayoutCountries

public async getPayoutCountries(): Promise<NoahGetPayoutCountriesResponse>
ReturnsPromise<NoahGetPayoutCountriesResponse> with data.countries.

getPayoutChannels

public async getPayoutChannels(data: NoahGetPayoutChannelsRequest): Promise<NoahGetPayoutChannelsResponse>
ParameterTypeDescription
dataNoahGetPayoutChannelsRequestcountry, cryptoCurrency, fiatCurrency, optional fiatAmount
ReturnsPromise<NoahGetPayoutChannelsResponse> (data shape is provider-specific).

getPayoutChannelForm

public async getPayoutChannelForm(channelId: string): Promise<NoahGetPayoutChannelFormResponse>
ParameterTypeDescription
channelIdstringPayout channel id from getPayoutChannels
ReturnsPromise<NoahGetPayoutChannelFormResponse> (dynamic form schema).

getPayoutQuote

public async getPayoutQuote(data: NoahGetPayoutQuoteRequest): Promise<NoahGetPayoutQuoteResponse>
ParameterTypeDescription
dataNoahGetPayoutQuoteRequestchannelId, cryptoCurrency, fiatAmount, optional form, fiatCurrency, paymentMethodId
ReturnsPromise<NoahGetPayoutQuoteResponse> including payoutId, formSessionId, cryptoAmountEstimate, totalFee.

initiatePayout

public async initiatePayout(data: NoahInitiatePayoutRequest): Promise<NoahInitiatePayoutResponse>
ParameterTypeDescription
dataNoahInitiatePayoutRequestpayoutId, sourceAddress, ISO expiry, nonce, CAIP-2 network, optional trigger
ReturnsPromise<NoahInitiatePayoutResponse> with destinationAddress and conditions for deposit legs when applicable.

getPaymentMethods

public async getPaymentMethods(): Promise<NoahGetPaymentMethodsResponse>
ReturnsPromise<NoahGetPaymentMethodsResponse> with data.paymentMethods and optional pageToken.

Deprecated Methods

The following methods are deprecated. Use portal.request() instead.

ethEstimateGas

Deprecated: Use portal.request({ method: 'eth_estimateGas', ... }) instead.
public async ethEstimateGas(chainId: string, transaction: EthereumTransaction): Promise<any>

ethGasPrice

Deprecated: Use portal.request({ method: 'eth_gasPrice', ... }) instead.
public async ethGasPrice(chainId: string): Promise<string>

ethGetBalance

Deprecated: Use portal.request({ method: 'eth_getBalance', ... }) instead.
public async ethGetBalance(chainId: string): Promise<string>

ethSendTransaction

Deprecated: Use portal.request({ method: 'eth_sendTransaction', ... }) instead.
public async ethSendTransaction(chainId: string, transaction: EthereumTransaction): Promise<string>

ethSignTransaction

Deprecated: Use portal.request({ method: 'eth_signTransaction', ... }) instead.
public async ethSignTransaction(chainId: string, transaction: EthereumTransaction): Promise<string>

ethSignTypedData

Deprecated: Use portal.request({ method: 'eth_signTypedData', ... }) instead.
public async ethSignTypedData(chainId: string, data: TypedData): Promise<string>

ethSignTypedDataV3

Deprecated: Use portal.request({ method: 'eth_signTypedData_v3', ... }) instead.
public async ethSignTypedDataV3(chainId: string, data: TypedData): Promise<string>

ethSignTypedDataV4

Deprecated: Use portal.request({ method: 'eth_signTypedData_v4', ... }) instead.
public async ethSignTypedDataV4(chainId: string, data: TypedData): Promise<string>

personalSign

Deprecated: Use portal.request({ method: 'personal_sign', ... }) instead.
public async personalSign(chainId: string, message: string): Promise<string>

getBalances

Deprecated: Use portal.getAssets() instead.
public async getBalances(chainId: string): Promise<Balance[]>

getNFTs

Deprecated: Use portal.getNFTAssets() instead.
public async getNFTs(chainId: string): Promise<NFT[]>

simulateTransaction

Deprecated: Use portal.evaluateTransaction() instead.
public async simulateTransaction(
  chainId: string,
  transaction: SimulateTransactionParam
): Promise<SimulatedTransaction>