> ## 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.

# Reference

> Read the reference documentation for the Portal Web SDK.

## 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.

```typescript theme={null}
constructor(options: PortalOptions)
```

**Parameters**

| Name                   | Type            | Required | Default                    | Description                                                                                                                |
| ---------------------- | --------------- | -------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `options.rpcConfig`    | `RpcConfig`     | Yes      | -                          | Configuration object mapping chain IDs to RPC URLs (e.g., `{ "eip155:1": "https://..." }`)                                 |
| `options.apiKey`       | `string`        | No       | -                          | Portal API key for authentication                                                                                          |
| `options.authToken`    | `string`        | No       | -                          | Authentication token for Portal services                                                                                   |
| `options.authUrl`      | `string`        | No       | -                          | Custom authentication URL                                                                                                  |
| `options.autoApprove`  | `boolean`       | No       | `false`                    | Automatically approve transactions without user confirmation                                                               |
| `options.gdrive`       | `GDriveConfig`  | No       | -                          | Google Drive backup configuration with `clientId`                                                                          |
| `options.passkey`      | `PasskeyConfig` | No       | -                          | Passkey configuration for WebAuthn backup                                                                                  |
| `options.host`         | `string`        | No       | `'web.portalhq.io'`        | Portal host URL                                                                                                            |
| `options.mpcVersion`   | `string`        | No       | `'v6'`                     | MPC protocol version                                                                                                       |
| `options.mpcHost`      | `string`        | No       | `'mpc-client.portalhq.io'` | MPC service host                                                                                                           |
| `options.featureFlags` | `FeatureFlags`  | No       | `{}`                       | Feature flags configuration                                                                                                |
| `options.chainId`      | `string`        | No       | -                          | Default chain ID for the provider                                                                                          |
| `options.logLevel`     | `LogLevel`      | No       | `'none'`                   | Logging level: `'none'`, `'error'`, `'warn'`, `'info'`, or `'debug'`. See [Logging Configuration](/sdks/web/guide/logging) |
| `options.logger`       | `ILogger`       | No       | `console`                  | Custom logger implementing `error`, `warn`, `info`, and `debug` methods                                                    |

**Example Usage**

```typescript theme={null}
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

| Property        | Type                         | Description                                                                                         |
| --------------- | ---------------------------- | --------------------------------------------------------------------------------------------------- |
| `address`       | `string \| undefined`        | The current wallet address                                                                          |
| `apiKey`        | `string \| undefined`        | Portal API key                                                                                      |
| `authToken`     | `string \| undefined`        | Authentication token                                                                                |
| `authUrl`       | `string \| undefined`        | Authentication URL                                                                                  |
| `autoApprove`   | `boolean`                    | Auto-approve transactions setting                                                                   |
| `gDriveConfig`  | `GDriveConfig \| undefined`  | Google Drive configuration                                                                          |
| `passkeyConfig` | `PasskeyConfig \| undefined` | Passkey configuration                                                                               |
| `host`          | `string`                     | Portal host URL                                                                                     |
| `mpc`           | `Mpc`                        | MPC instance for wallet operations                                                                  |
| `yield`         | `Yield`                      | [Yield.xyz integration](/integrations/Yield/yield-xyz) instance                                     |
| `trading`       | `Trading`                    | [LiFi trading integration](/integrations/Trading/lifi) instance                                     |
| `ramps`         | `Ramps`                      | [Noah virtual accounts and payouts](/integrations/On-Off-Ramp/noah) namespace (`portal.ramps.noah`) |
| `mpcHost`       | `string`                     | MPC service host                                                                                    |
| `mpcVersion`    | `string`                     | MPC protocol version                                                                                |
| `provider`      | `Provider`                   | Provider instance for RPC requests                                                                  |
| `featureFlags`  | `FeatureFlags`               | Feature flags configuration                                                                         |
| `ready`         | `boolean`                    | Whether the Portal instance is ready (read-only getter)                                             |

### Feature flags

The `featureFlags` option controls optional SDK behavior. Pass it when creating a `Portal` instance.

| Property           | Type      | Default | Description                                                                                                                                                                                                                                                                                          |
| ------------------ | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `usePresignatures` | `boolean` | `false` | When `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](/sdks/web/guide/feature-flags#usepresignatures) for details. |

**Example**

```typescript theme={null}
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.

```typescript theme={null}
public setLogLevel(level: LogLevel): void
```

**Parameters**

| Name    | Type       | Description                                                  |
| ------- | ---------- | ------------------------------------------------------------ |
| `level` | `LogLevel` | One of `'none'`, `'error'`, `'warn'`, `'info'`, or `'debug'` |

**Example Usage**

```typescript theme={null}
portal.setLogLevel('debug')  // Enable verbose logging
portal.setLogLevel('none')   // Disable all SDK logs
```

See [Logging Configuration](/sdks/web/guide/logging) for full details.

### getLogLevel

Returns the current SDK log level.

```typescript theme={null}
public getLogLevel(): LogLevel
```

**Returns**

`LogLevel` — The current level: `'none' | 'error' | 'warn' | 'info' | 'debug'`

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public onReady(callback: () => any | Promise<any>): () => void
```

**Parameters**

| Name       | Type                        | Description                    |
| ---------- | --------------------------- | ------------------------------ |
| `callback` | `() => any \| Promise<any>` | Function to execute when ready |

**Returns**

A cleanup function that removes the callback when called.

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public onInitializationError(callback: (reason: string) => any | Promise<any>): () => void
```

**Parameters**

| Name       | Type                                      | Description                                         |
| ---------- | ----------------------------------------- | --------------------------------------------------- |
| `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**

```typescript theme={null}
const unsubscribe = portal.onInitializationError(reason => {
  console.error('Initialization failed:', reason);
});
```

***

## Wallet Lifecycle Methods

### createWallet

Creates a new wallet and generates addresses for supported chains.

```typescript theme={null}
public async createWallet(progress?: ProgressCallback): Promise<string>
```

**Parameters**

| Name       | Type               | Description                                                      |
| ---------- | ------------------ | ---------------------------------------------------------------- |
| `progress` | `ProgressCallback` | Optional callback for tracking progress with `MpcStatus` updates |

**Returns**

`Promise<string>` - The wallet address

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async backupWallet(
  backupMethod: BackupMethods,
  progress?: ProgressCallback,
  backupConfigs?: BackupConfigs
): Promise<BackupResponse>
```

**Parameters**

| Name            | Type               | Description                                       |
| --------------- | ------------------ | ------------------------------------------------- |
| `backupMethod`  | `BackupMethods`    | Backup method: `GDRIVE`, `PASSWORD`, or `PASSKEY` |
| `progress`      | `ProgressCallback` | Optional progress callback                        |
| `backupConfigs` | `BackupConfigs`    | Optional backup configuration (e.g., password)    |

**Returns**

`Promise<BackupResponse>` containing:

* `cipherText`: Encrypted backup data
* `storageCallback`: Function to finalize storage

**Example Usage**

```typescript theme={null}
// 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.

```typescript theme={null}
public async recoverWallet(
  cipherText: string,
  backupMethod: BackupMethods,
  backupConfigs?: BackupConfigs,
  progress?: ProgressCallback
): Promise<string>
```

**Parameters**

| Name            | Type               | Description                   |
| --------------- | ------------------ | ----------------------------- |
| `cipherText`    | `string`           | Encrypted backup data         |
| `backupMethod`  | `BackupMethods`    | Backup method used            |
| `backupConfigs` | `BackupConfigs`    | Optional backup configuration |
| `progress`      | `ProgressCallback` | Optional progress callback    |

**Returns**

`Promise<string>` - The recovered wallet address

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async provisionWallet(
  cipherText: string,
  backupMethod: BackupMethods,
  backupConfigs: BackupConfigs,
  progress?: ProgressCallback
): Promise<string>
```

### clearLocalWallet

Clears the local wallet data from device storage.

```typescript theme={null}
public async clearLocalWallet(): Promise<boolean>
```

**Returns**

`Promise<boolean>` - `true` if successful

**Example Usage**

```typescript theme={null}
const cleared = await portal.clearLocalWallet();
console.log('Wallet cleared:', cleared);
```

***

## Wallet Status Methods

### doesWalletExist

Checks if a wallet exists for the client.

```typescript theme={null}
public async doesWalletExist(chainId?: string): Promise<boolean>
```

**Parameters**

| Name      | Type     | Description                                                        |
| --------- | -------- | ------------------------------------------------------------------ |
| `chainId` | `string` | Optional chain ID to check specific namespace (e.g., `'eip155:1'`) |

**Returns**

`Promise<boolean>` - `true` if wallet exists

**Example Usage**

```typescript theme={null}
// 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.

```typescript theme={null}
public async isWalletOnDevice(chainId?: string): Promise<boolean>
```

**Parameters**

| Name      | Type     | Description                               |
| --------- | -------- | ----------------------------------------- |
| `chainId` | `string` | Optional chain ID to check specific curve |

**Returns**

`Promise<boolean>` - `true` if wallet is on device

### isWalletBackedUp

Checks if the wallet has been backed up.

```typescript theme={null}
public async isWalletBackedUp(chainId?: string): Promise<boolean>
```

**Parameters**

| Name      | Type     | Description                                |
| --------- | -------- | ------------------------------------------ |
| `chainId` | `string` | Optional chain ID to check specific wallet |

**Returns**

`Promise<boolean>` - `true` if wallet is backed up

### isWalletRecoverable

Checks if the wallet can be recovered.

```typescript theme={null}
public async isWalletRecoverable(chainId?: string): Promise<boolean>
```

**Returns**

`Promise<boolean>` - `true` if wallet is recoverable

### availableRecoveryMethods

Gets the available recovery methods for the wallet.

```typescript theme={null}
public async availableRecoveryMethods(chainId?: string): Promise<BackupMethods[]>
```

**Returns**

`Promise<BackupMethods[]>` - Array of available backup methods

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async getEip155Address(): Promise<string>
```

**Returns**

`Promise<string>` - The Ethereum address

**Example Usage**

```typescript theme={null}
const ethAddress = await portal.getEip155Address();
console.log('Ethereum address:', ethAddress);
```

### getSolanaAddress

Gets the Solana address.

```typescript theme={null}
public async getSolanaAddress(): Promise<string>
```

**Returns**

`Promise<string>` - The Solana address

**Example Usage**

```typescript theme={null}
const solAddress = await portal.getSolanaAddress();
console.log('Solana address:', solAddress);
```

***

## Eject Methods

<Warning>
  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!
</Warning>

### eject

Ejects the SECP256K1 private key from MPC custody. For eject examples see [here](./guide/eject-a-wallet)

```typescript theme={null}
public async eject(
  backupMethod: BackupMethods,
  backupConfigs: BackupConfigs,
  orgBackupShare?: string,
  clientBackupCipherText?: string
): Promise<EjectResult>
```

**Parameters**

| Name                     | Type            | Description                                                     |
| ------------------------ | --------------- | --------------------------------------------------------------- |
| `backupMethod`           | `BackupMethods` | Backup method to use                                            |
| `backupConfigs`          | `BackupConfigs` | Backup configuration                                            |
| `orgBackupShare`         | `string`        | Organization backup share (required if not using Portal backup) |
| `clientBackupCipherText` | `string`        | Client 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.

```typescript theme={null}
public async ejectPrivateKeys(
  backupMethod: BackupMethods,
  backupConfigs: BackupConfigs,
  orgBackupShares: OrgBackupShares,
  clientBackupCipherText?: string
): Promise<EjectPrivateKeysResult>
```

**Parameters**

| Name                     | Type              | Description                                                     |
| ------------------------ | ----------------- | --------------------------------------------------------------- |
| `backupMethod`           | `BackupMethods`   | Backup method to use                                            |
| `backupConfigs`          | `BackupConfigs`   | Backup configuration                                            |
| `orgBackupShares`        | `OrgBackupShares` | Organization backup shares for both curves                      |
| `clientBackupCipherText` | `string`          | Client 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.

```typescript theme={null}
public async request(request: RequestArguments): Promise<any>
```

**Parameters**

| Name                            | Type      | Description                                                          |
| ------------------------------- | --------- | -------------------------------------------------------------------- |
| `request.chainId`               | `string`  | Chain ID in CAIP-2 format (e.g., `'eip155:1'`)                       |
| `request.method`                | `string`  | RPC method name (e.g., `'eth_sendTransaction'`)                      |
| `request.params`                | `any`     | Method parameters                                                    |
| `request.sponsorGas`            | `boolean` | Optional. Whether to sponsor gas (Account Abstraction).              |
| `request.signatureApprovalMemo` | `string`  | Optional. Memo shown to the user during the signature approval flow. |

**Returns**

`Promise<any>` - Response from the RPC call

**Example Usage**

```typescript theme={null}
// 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.

```typescript theme={null}
public async sendAsset(chain: string, params: SendAssetParams): Promise<SendAssetResponse>
```

**Parameters**

| Name                           | Type      | Description                                                          |
| ------------------------------ | --------- | -------------------------------------------------------------------- |
| `chain`                        | `string`  | Chain ID or friendly name (e.g., `'ethereum'`, `'solana'`)           |
| `params.to`                    | `string`  | Recipient address                                                    |
| `params.token`                 | `string`  | Token contract address or native token identifier                    |
| `params.amount`                | `string`  | Amount to send                                                       |
| `params.sponsorGas`            | `boolean` | Optional. Whether to sponsor gas (Account Abstraction).              |
| `params.signatureApprovalMemo` | `string`  | Optional. Memo shown to the user during the signature approval flow. |

**Returns**

`Promise<SendAssetResponse>` containing transaction hash and metadata

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async sendSol({
  chainId,
  to,
  lamports
}: {
  chainId: string
  to: string
  lamports: number
}): Promise<string>
```

**Parameters**

| Name       | Type     | Description                                         |
| ---------- | -------- | --------------------------------------------------- |
| `chainId`  | `string` | Solana chain ID (must start with `'solana:'`)       |
| `to`       | `string` | Recipient Solana address (44 characters)            |
| `lamports` | `number` | Amount in lamports (1 SOL = 1,000,000,000 lamports) |

**Returns**

`Promise<string>` - Transaction signature

**Example Usage**

```typescript theme={null}
const signature = await portal.sendSol({
  chainId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
  to: 'DYw8...',
  lamports: 1000000000, // 1 SOL
});
```

### sendEth

Helper method to send ETH.

```typescript theme={null}
public sendEth = async ({
  chainId,
  to,
  value
}: {
  chainId: string
  to: string
  value: string
}): Promise<any>
```

**Parameters**

| Name      | Type     | Description                |
| --------- | -------- | -------------------------- |
| `chainId` | `string` | EIP-155 chain ID           |
| `to`      | `string` | Recipient address          |
| `value`   | `string` | Amount in wei (hex string) |

**Returns**

`Promise<any>` - Transaction hash

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async rawSign(
  curve: PortalCurve,
  param: string,
  options?: RawSignOptions
): Promise<string>
```

**Parameters**

| Name      | Type             | Description                                    |
| --------- | ---------------- | ---------------------------------------------- |
| `curve`   | `PortalCurve`    | Cryptographic curve (`ED25519` or `SECP256K1`) |
| `param`   | `string`         | Data to sign                                   |
| `options` | `RawSignOptions` | Optional. `{ signatureApprovalMemo?: string }` |

**Returns**

`Promise<string>` - Signature

**Example Usage**

```typescript theme={null}
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);
```

***

## API Methods

### getClient

Gets information about the client and their wallets.

```typescript theme={null}
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**

```typescript theme={null}
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.

```typescript theme={null}
public async getAssets(chainId: string, includeNfts?: boolean): Promise<GetAssetsResponse>
```

**Parameters**

| Name          | Type      | Description                                |
| ------------- | --------- | ------------------------------------------ |
| `chainId`     | `string`  | Chain ID to query                          |
| `includeNfts` | `boolean` | Whether to include NFTs (default: `false`) |

**Returns**

`Promise<GetAssetsResponse>` with asset information

**Example Usage**

```typescript theme={null}
const assets = await portal.getAssets('eip155:1', false);
console.log('Assets:', assets);
```

### getNFTAssets

Gets NFT assets held by the wallet.

```typescript theme={null}
public async getNFTAssets(chainId: string): Promise<NFTAsset[]>
```

**Parameters**

| Name      | Type     | Description       |
| --------- | -------- | ----------------- |
| `chainId` | `string` | Chain ID to query |

**Returns**

`Promise<NFTAsset[]>` - Array of NFT assets

**Example Usage**

```typescript theme={null}
const nfts = await portal.getNFTAssets('eip155:1');
console.log('NFT assets:', nfts);
```

### getTransactions

Gets transaction history for the wallet.

```typescript theme={null}
public async getTransactions(
  chainId: string,
  limit?: number,
  offset?: number,
  order?: GetTransactionsOrder
): Promise<Transaction[]>
```

**Parameters**

| Name      | Type                   | Description                              |
| --------- | ---------------------- | ---------------------------------------- |
| `chainId` | `string`               | Chain ID to query                        |
| `limit`   | `number`               | Maximum number of transactions to return |
| `offset`  | `number`               | Number of transactions to skip           |
| `order`   | `GetTransactionsOrder` | Sort order: `'asc'` or `'desc'`          |

**Returns**

`Promise<Transaction[]>` - Array of transactions

**Example Usage**

```typescript theme={null}
import { GetTransactionsOrder } from '@portal-hq/web';

const txs = await portal.getTransactions('eip155:1', 10, 0, GetTransactionsOrder.DESC);
```

### evaluateTransaction

Evaluates a transaction before execution to check if the transaction can be executed, and perform security validations.

```typescript theme={null}
public async evaluateTransaction(
  chainId: string,
  transaction: EvaluateTransactionParam,
  operationType?: EvaluateTransactionOperationType
): Promise<EvaluatedTransaction>
```

**Parameters**

| Name            | Type                               | Description                           |
| --------------- | ---------------------------------- | ------------------------------------- |
| `chainId`       | `string`                           | Chain ID                              |
| `transaction`   | `EvaluateTransactionParam`         | Transaction to evaluate               |
| `operationType` | `EvaluateTransactionOperationType` | Type of evaluation (default: `'all'`) |

**Returns**

`Promise<EvaluatedTransaction>` with security analysis

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async buildTransaction(
  chainId: string,
  to: string,
  token: string,
  amount: string
): Promise<BuiltTransaction>
```

**Parameters**

| Name      | Type     | Description            |
| --------- | -------- | ---------------------- |
| `chainId` | `string` | Chain ID               |
| `to`      | `string` | Recipient address      |
| `token`   | `string` | Token contract address |
| `amount`  | `string` | Amount to send         |

**Returns**

`Promise<BuiltTransaction>` with the built transaction object

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async receiveTestnetAsset(chainId: string, params: FundParams): Promise<FundResponse>
```

**Parameters**

| Name            | Type     | Description       |
| --------------- | -------- | ----------------- |
| `chainId`       | `string` | Testnet chain ID  |
| `params.amount` | `string` | Amount to request |
| `params.token`  | `string` | Token identifier  |

**Returns**

`Promise<FundResponse>` with funding details

**Example Usage**

```typescript theme={null}
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.

<Warning>Deprecated: Use the `portal.trading.zerox.getQuote` method instead.</Warning>

```typescript theme={null}
public async getQuote(
  apiKey: string,
  args: QuoteArgs,
  chainId: string
): Promise<QuoteResponse>
```

### getSources

Gets available swap sources for in-chain swaps.

<Warning>Deprecated: Use the `portal.trading.zerox.getSources` method instead.</Warning>

```typescript theme={null}
public async getSources(apiKey: string, chainId: string): Promise<Record<string, string>>
```

***

## Utility Methods

### updateChain

Updates the current chain ID for the provider.

```typescript theme={null}
public updateChain(newChainId: string): void
```

**Parameters**

| Name         | Type     | Description         |
| ------------ | -------- | ------------------- |
| `newChainId` | `string` | New chain ID to set |

**Example Usage**

```typescript theme={null}
portal.updateChain('eip155:137'); // Switch to Polygon
```

### getRpcUrl

Gets the configured RPC URL for a chain.

```typescript theme={null}
public getRpcUrl(chainId?: string): string
```

**Parameters**

| Name      | Type     | Description         |
| --------- | -------- | ------------------- |
| `chainId` | `string` | Chain 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.

```typescript theme={null}
public async storedClientBackupShare(success: boolean, backupMethod: BackupMethods): Promise<void>
```

**Parameters**

| Name           | Type            | Description                       |
| -------------- | --------------- | --------------------------------- |
| `success`      | `boolean`       | Whether the backup was successful |
| `backupMethod` | `BackupMethods` | The backup method that was used   |

**Returns**

`Promise<void>`

**Example Usage**

```typescript theme={null}
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](/integrations/Yield/yield-xyz) integration for yield farming opportunities.

**Properties**

| Property   | Type       | Description                    |
| ---------- | ---------- | ------------------------------ |
| `yieldXyz` | `YieldXyz` | Yield.xyz integration instance |

### portal.yield.yieldXyz (YieldXyz)

Access yield farming features through the Yield.xyz integration.

#### discover

Discovers available yield opportunities.

```typescript theme={null}
public async discover(data: YieldXyzGetYieldsRequest): Promise<YieldXyzGetYieldsResponse>
```

**Parameters**

| Name   | Type                       | Description                    |
| ------ | -------------------------- | ------------------------------ |
| `data` | `YieldXyzGetYieldsRequest` | Parameters for yield discovery |

**Returns**

`Promise<YieldXyzGetYieldsResponse>` - Available yield opportunities

**Example Usage**

```typescript theme={null}
const yields = await portal.yield.yieldXyz.discover({
  // Discovery parameters
});
console.log('Available yields:', yields);
```

#### getBalances

Retrieves yield balances for specified addresses and networks.

```typescript theme={null}
public async getBalances(data: YieldXyzGetBalancesRequest): Promise<YieldXyzGetBalancesResponse>
```

**Parameters**

| Name   | Type                         | Description                                         |
| ------ | ---------------------------- | --------------------------------------------------- |
| `data` | `YieldXyzGetBalancesRequest` | Request parameters including addresses and networks |

**Returns**

`Promise<YieldXyzGetBalancesResponse>` - Balance information

#### getHistoricalActions

Retrieves historical yield actions with optional filtering.

```typescript theme={null}
public async getHistoricalActions(
  data: YieldXyzGetHistoricalActionsRequest
): Promise<YieldXyzGetHistoricalActionsResponse>
```

**Returns**

`Promise<YieldXyzGetHistoricalActionsResponse>` - Historical actions

#### enter

Enters a yield opportunity.

```typescript theme={null}
public async enter(data: YieldXyzEnterRequest): Promise<YieldXyzEnterYieldResponse>
```

**Parameters**

| Name   | Type                   | Description                                 |
| ------ | ---------------------- | ------------------------------------------- |
| `data` | `YieldXyzEnterRequest` | Parameters for entering a yield opportunity |

**Returns**

`Promise<YieldXyzEnterYieldResponse>` - Action details

**Example Usage**

```typescript theme={null}
const result = await portal.yield.yieldXyz.enter({
  // Enter parameters
});
```

#### exit

Exits a yield opportunity.

```typescript theme={null}
public async exit(data: YieldXyzExitRequest): Promise<YieldXyzExitResponse>
```

**Parameters**

| Name   | Type                  | Description                                |
| ------ | --------------------- | ------------------------------------------ |
| `data` | `YieldXyzExitRequest` | Parameters for exiting a yield opportunity |

**Returns**

`Promise<YieldXyzExitResponse>` - Action details

#### manage

Manages a yield opportunity with specified parameters.

```typescript theme={null}
public async manage(data: YieldXyzManageYieldRequest): Promise<YieldXyzManageYieldResponse>
```

**Parameters**

| Name   | Type                         | Description                                 |
| ------ | ---------------------------- | ------------------------------------------- |
| `data` | `YieldXyzManageYieldRequest` | Parameters for managing a yield opportunity |

**Returns**

`Promise<YieldXyzManageYieldResponse>` - Action details

#### track

Tracks a transaction by submitting its hash.

```typescript theme={null}
public async track(data: YieldXyzTrackTransactionRequest): Promise<YieldXyzTrackTransactionResponse>
```

**Parameters**

| Name                 | Type     | Description                           |
| -------------------- | -------- | ------------------------------------- |
| `data.transactionId` | `string` | The ID of the transaction to track    |
| `data.txHash`        | `string` | The hash of the transaction to submit |

**Returns**

`Promise<YieldXyzTrackTransactionResponse>` - Tracking confirmation

#### getTransaction

Retrieves a single yield action transaction by its ID.

```typescript theme={null}
public async getTransaction(transactionId: string): Promise<YieldXyzGetTransactionResponse>
```

**Parameters**

| Name            | Type     | Description                    |
| --------------- | -------- | ------------------------------ |
| `transactionId` | `string` | The transaction ID to retrieve |

**Returns**

`Promise<YieldXyzGetTransactionResponse>` - Transaction details

***

### portal.trading (Trading)

The `Trading` class provides access to:

* [Li.Fi](/integrations/Trading/lifi) integration for cross-chain swaps and bridges
* [0x](./guide/perform-swaps) integration for in-chain swaps

**Properties**

| Property | Type    | Description                |
| -------- | ------- | -------------------------- |
| `lifi`   | `LiFi`  | Li.Fi integration instance |
| `zeroX`  | `ZeroX` | 0x integration instance    |

### portal.trading.lifi (LiFi)

Access cross-chain swap and bridge features through the Li.Fi integration.

#### getRoutes

Retrieves available routes for cross-chain swaps and bridges.

```typescript theme={null}
public async getRoutes(data: LifiRoutesRequest): Promise<LifiRoutesResponse>
```

**Parameters**

| Name   | Type                | Description                    |
| ------ | ------------------- | ------------------------------ |
| `data` | `LifiRoutesRequest` | Parameters for route discovery |

**Returns**

`Promise<LifiRoutesResponse>` - Available routes

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async getQuote(data: LifiQuoteRequest): Promise<LifiQuoteResponse>
```

**Parameters**

| Name   | Type               | Description                      |
| ------ | ------------------ | -------------------------------- |
| `data` | `LifiQuoteRequest` | Parameters for the quote request |

**Returns**

`Promise<LifiQuoteResponse>` - Quote details including fees and estimated time

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async getStatus(data: LifiStatusRequest): Promise<LifiStatusResponse>
```

**Parameters**

| Name   | Type                | Description                                          |
| ------ | ------------------- | ---------------------------------------------------- |
| `data` | `LifiStatusRequest` | Status request parameters including transaction hash |

**Returns**

`Promise<LifiStatusResponse>` - Transaction status

**Example Usage**

```typescript theme={null}
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.

```typescript theme={null}
public async getRouteStep(data: LifiStepTransactionRequest): Promise<LifiStepTransactionResponse>
```

**Parameters**

| Name   | Type                         | Description                                |
| ------ | ---------------------------- | ------------------------------------------ |
| `data` | `LifiStepTransactionRequest` | Step transaction request with step details |

**Returns**

`Promise<LifiStepTransactionResponse>` - Unsigned transaction ready to be signed

**Example Usage**

```typescript theme={null}
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)

#### getQuote

Gets a quote for an in-chain token swap.

```typescript theme={null}
public async getQuote(
  apiKey: string,
  args: QuoteArgs,
  chainId: string
): Promise<QuoteResponse>
```

#### getSources

Gets available swap sources for in-chain swaps.

```typescript theme={null}
public async getSources(apiKey: string, chainId: string): Promise<Record<string, string>>
```

***

### portal.ramps (Ramps)

The `Ramps` class groups virtual account and payout integrations. Today it exposes Noah only.

**Properties**

| Property | Type   | Description                                     |
| -------- | ------ | ----------------------------------------------- |
| `noah`   | `Noah` | [Noah](/integrations/On-Off-Ramp/noah) ramp API |

See the [Noah Web SDK guide](./guide/noah) for end-to-end flows, prerequisites, and Noah [Business API / EMM](https://docs.noah.com/) 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

```typescript theme={null}
public async initiateKyc(data: NoahInitiateKycRequest): Promise<NoahInitiateKycResponse>
```

| Parameter | Type                     | Description                                                                     |
| --------- | ------------------------ | ------------------------------------------------------------------------------- |
| `data`    | `NoahInitiateKycRequest` | `returnUrl` (HTTPS), optional `fiatOptions`, `customerType`, `metadata`, `form` |

**Returns** — `Promise<NoahInitiateKycResponse>` with `data.hostedUrl` for hosted onboarding.

#### initiatePayin

```typescript theme={null}
public async initiatePayin(data: NoahInitiatePayinRequest): Promise<NoahInitiatePayinResponse>
```

| Parameter | Type                       | Description                                                              |
| --------- | -------------------------- | ------------------------------------------------------------------------ |
| `data`    | `NoahInitiatePayinRequest` | `fiatCurrency`, `cryptoCurrency`, CAIP-2 `network`, `destinationAddress` |

**Returns** — `Promise<NoahInitiatePayinResponse>` with `data.payinId` and `data.bankDetails`.

#### simulatePayin

```typescript theme={null}
public async simulatePayin(data: NoahSimulatePayinRequest): Promise<NoahSimulatePayinResponse>
```

| Parameter | Type                       | Description                                     |
| --------- | -------------------------- | ----------------------------------------------- |
| `data`    | `NoahSimulatePayinRequest` | `paymentMethodId`, `fiatAmount`, `fiatCurrency` |

**Returns** — `Promise<NoahSimulatePayinResponse>` (sandbox simulation payload).

#### getPayoutCountries

```typescript theme={null}
public async getPayoutCountries(): Promise<NoahGetPayoutCountriesResponse>
```

**Returns** — `Promise<NoahGetPayoutCountriesResponse>` with `data.countries`.

#### getPayoutChannels

```typescript theme={null}
public async getPayoutChannels(data: NoahGetPayoutChannelsRequest): Promise<NoahGetPayoutChannelsResponse>
```

| Parameter | Type                           | Description                                                        |
| --------- | ------------------------------ | ------------------------------------------------------------------ |
| `data`    | `NoahGetPayoutChannelsRequest` | `country`, `cryptoCurrency`, `fiatCurrency`, optional `fiatAmount` |

**Returns** — `Promise<NoahGetPayoutChannelsResponse>` (`data` shape is provider-specific).

#### getPayoutChannelForm

```typescript theme={null}
public async getPayoutChannelForm(channelId: string): Promise<NoahGetPayoutChannelFormResponse>
```

| Parameter   | Type     | Description                                |
| ----------- | -------- | ------------------------------------------ |
| `channelId` | `string` | Payout channel id from `getPayoutChannels` |

**Returns** — `Promise<NoahGetPayoutChannelFormResponse>` (dynamic form schema).

#### getPayoutQuote

```typescript theme={null}
public async getPayoutQuote(data: NoahGetPayoutQuoteRequest): Promise<NoahGetPayoutQuoteResponse>
```

| Parameter | Type                        | Description                                                                                     |
| --------- | --------------------------- | ----------------------------------------------------------------------------------------------- |
| `data`    | `NoahGetPayoutQuoteRequest` | `channelId`, `cryptoCurrency`, `fiatAmount`, optional `form`, `fiatCurrency`, `paymentMethodId` |

**Returns** — `Promise<NoahGetPayoutQuoteResponse>` including `payoutId`, `formSessionId`, `cryptoAmountEstimate`, `totalFee`.

#### initiatePayout

```typescript theme={null}
public async initiatePayout(data: NoahInitiatePayoutRequest): Promise<NoahInitiatePayoutResponse>
```

| Parameter | Type                        | Description                                                                              |
| --------- | --------------------------- | ---------------------------------------------------------------------------------------- |
| `data`    | `NoahInitiatePayoutRequest` | `payoutId`, `sourceAddress`, ISO `expiry`, `nonce`, CAIP-2 `network`, optional `trigger` |

**Returns** — `Promise<NoahInitiatePayoutResponse>` with `destinationAddress` and `conditions` for deposit legs when applicable.

#### getPaymentMethods

```typescript theme={null}
public async getPaymentMethods(): Promise<NoahGetPaymentMethodsResponse>
```

**Returns** — `Promise<NoahGetPaymentMethodsResponse>` with `data.paymentMethods` and optional `pageToken`.

***

## Deprecated Methods

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

### ethEstimateGas

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_estimateGas', ... })` instead.
</Warning>

```typescript theme={null}
public async ethEstimateGas(chainId: string, transaction: EthereumTransaction): Promise<any>
```

### ethGasPrice

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_gasPrice', ... })` instead.
</Warning>

```typescript theme={null}
public async ethGasPrice(chainId: string): Promise<string>
```

### ethGetBalance

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_getBalance', ... })` instead.
</Warning>

```typescript theme={null}
public async ethGetBalance(chainId: string): Promise<string>
```

### ethSendTransaction

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_sendTransaction', ... })` instead.
</Warning>

```typescript theme={null}
public async ethSendTransaction(chainId: string, transaction: EthereumTransaction): Promise<string>
```

### ethSignTransaction

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_signTransaction', ... })` instead.
</Warning>

```typescript theme={null}
public async ethSignTransaction(chainId: string, transaction: EthereumTransaction): Promise<string>
```

### ethSignTypedData

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_signTypedData', ... })` instead.
</Warning>

```typescript theme={null}
public async ethSignTypedData(chainId: string, data: TypedData): Promise<string>
```

### ethSignTypedDataV3

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_signTypedData_v3', ... })` instead.
</Warning>

```typescript theme={null}
public async ethSignTypedDataV3(chainId: string, data: TypedData): Promise<string>
```

### ethSignTypedDataV4

<Warning>
  Deprecated: Use `portal.request({ method: 'eth_signTypedData_v4', ... })` instead.
</Warning>

```typescript theme={null}
public async ethSignTypedDataV4(chainId: string, data: TypedData): Promise<string>
```

### personalSign

<Warning>
  Deprecated: Use `portal.request({ method: 'personal_sign', ... })` instead.
</Warning>

```typescript theme={null}
public async personalSign(chainId: string, message: string): Promise<string>
```

### getBalances

<Warning>Deprecated: Use `portal.getAssets()` instead.</Warning>

```typescript theme={null}
public async getBalances(chainId: string): Promise<Balance[]>
```

### getNFTs

<Warning>Deprecated: Use `portal.getNFTAssets()` instead.</Warning>

```typescript theme={null}
public async getNFTs(chainId: string): Promise<NFT[]>
```

### simulateTransaction

<Warning>Deprecated: Use `portal.evaluateTransaction()` instead.</Warning>

```typescript theme={null}
public async simulateTransaction(
  chainId: string,
  transaction: SimulateTransactionParam
): Promise<SimulatedTransaction>
```

***
