Skip to main content

portal.api

The api property contains an instance of the PortalApi class, which has a number of helper methods to facilitate the retrieval of relevant application data from the Portal REST API.

portal.api.buildTransaction

Creates an unsigned eip155/solana transaction for transferring assets to another address on a specific chain. You can then use this unsigned eip155/solana transaction to sign and submit the eip155/solana transaction.
const txDetails = await portal.api.buildTransaction(
  '0xDestinationAddress',
  'USDC', // Friendly token name, or token address (mint address for Solana)
  '1', // Sends 1 USDC
  'monad-testnet', // Friendly chain or CAIP-2 chainId
)

portal.api.getNFTs

Fetches a list of non-fungible tokens (NFTs). The response is an array of objects where each object represents a unique NFT.
const nfts = await portal.api.getNFTs()

portal.api.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.
const evmTxs = await portal.api.getTransactionHistory({
  chainId: 'eip155:1',
  limit: 20,
  order: 'desc',
  userOperations: 'include', // Include both regular txs and UserOps (EVM only)
})
Optional parameters:
  • limit: (Optional) Maximum number of transactions to return (default: 50; max: 1000 for EVM, 15 for Solana).
  • offset: (Optional) Number of transactions to skip for pagination (default: 0).
  • order: (Optional) Sort order by block number: "asc" or "desc" (default: "desc", EVM only).
  • address: (Optional) Address override (EVM only).
  • userOperations: (Optional) Filter ERC-4337 UserOperations on EVM chains (eip155:*) only: "include", "only", or "exclude". If omitted on EVM, the SDK sends userOperations=only when the client has Account Abstraction enabled; otherwise the parameter is not sent. Non-EVM chains never use this filter.

portal.api.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 a list of the client’s transaction history ordered by blockTimestamp descending (latest transactions will come first). This includes both inbound and outbound transactions.
const transactions = await portal.api.getTransactions()
Optional arguments can also be provided:
  • limit: (Optional) The maximum number of transactions to return.
  • offset: (Optional) The number of transactions to skip before starting to return.
  • order: (Optional) Order in which to return the transactions. Either "asc" or "desc".
  • chainId: (Optional) ID of the chain to retrieve transactions from. Defaults to your Portal instance’s chainId if not provided.

portal.api.getBalances

Fetches a list of the client’s ERC20 token balances.
const tokenBalances = await portal.api.getBalances()

portal.api.getBackupShareMetadata

Fetches a list of the client’s backup shares’ metadata, such as the backup method, when it was created, and the backup share’s id.
const backupSharePairs = await portal.api.getBackupShareMetadata()