Api

open class Api(apiHost: String, apiKey: String, requests: PortalRequests = PortalRequests(), provider: Provider, featureFlags: FeatureFlags? = null)

The Api class provides an interface for interacting with the backend API.

It handles authentication, network requests, and response parsing for various endpoints related to client management, blockchain data, and analytics.

Parameters

apiHost

The base URL of the API server.

apiKey

The API key used for authentication.

requests

An instance of PortalRequests to handle HTTP requests. Defaults to a new instance.

provider

An instance of Provider to access device specific data.

featureFlags

An optional instance of FeatureFlags for feature flag management.

Constructors

Link copied to clipboard
constructor(apiHost: String, apiKey: String, requests: PortalRequests = PortalRequests(), provider: Provider, featureFlags: FeatureFlags? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val api: HttpRequester
Link copied to clipboard
val client: Deferred<ClientResponse?>

Asynchronously retrieves the client details using a coroutine.

Link copied to clipboard

Functions

Link copied to clipboard

Builds an EIP-155 compatible transaction for the specified blockchain.

Link copied to clipboard

Builds a Solana-compatible transaction for the specified blockchain.

Link copied to clipboard

Ejects the client from the system, removing their session.

Link copied to clipboard

Evaluates a transaction by validating its parameters.

Link copied to clipboard
open suspend fun getAssets(chainId: String): Result<GetAssetsByChainResponse>

Retrieves the list of fungible assets owned by the client on a specific blockchain.

Link copied to clipboard

Retrieves metadata for all stored backup share pairs associated with the client.

Link copied to clipboard
open suspend fun getClient(): ClientResponse

Fetches the client details from the API.

Link copied to clipboard
open suspend fun getClientCipherText(backupSharePairId: String): String

Retrieves the encrypted client backup share ciphertext associated with a given backup share pair ID.

Link copied to clipboard

Fetches the list of enabled decentralized applications (DApps) from the API.

Link copied to clipboard
open fun getNetworks(): List<Network>

Retrieves the list of available blockchain networks from the API.

Link copied to clipboard

Retrieves the list of NFT assets owned by the client on a specific blockchain.

Link copied to clipboard
open suspend fun getQuote(chainId: String, swapsApiKey: String, args: QuoteArgs): Result<Quote>

Retrieves a quote for a swap transaction on the specified blockchain.

Link copied to clipboard

Retrieves metadata for all stored signing share pairs associated with the client.

Link copied to clipboard
open suspend fun getSources(chainId: String, swapsApiKey: String): Result<Map<String, String>>

Retrieves the available sources for swap transactions on the specified blockchain.

Link copied to clipboard
open suspend fun getTransactions(chainId: String, limit: Int? = null, offset: Int? = null, order: GetTransactionsOrder? = null): Result<List<Transaction>>

Fetches a list of transactions associated with the client on a given blockchain.

Link copied to clipboard
fun identify(traits: Map<String, Any> = mapOf()): MetricsResponse

Identifies a user for analytics tracking by associating traits with them.

Link copied to clipboard
open suspend fun prepareEject(walletId: String, backupMethod: BackupMethods): String

Prepares the ejection of a wallet by obtaining the necessary share for the operation.

Link copied to clipboard
open suspend fun refreshClient()

Refreshes the client details by resetting the cached client and fetching updated information.

Link copied to clipboard
open suspend fun storeClientCipherText(backupSharePairId: String, cipherText: String): Boolean

Stores the encrypted client backup share ciphertext for a given backup share pair ID.

Link copied to clipboard

Marks the client backup share as stored by the organization.

Link copied to clipboard
open fun storedClientBackupShareKey(success: Boolean, backupMethod: BackupMethods): Result<Boolean>

Marks the client backup share key as stored by the organization.

Link copied to clipboard
open fun storedClientSigningShare(signingSharePairId: String): Boolean

Marks a client signing share as stored by the organization.

Link copied to clipboard
fun track(event: String, properties: Map<String, Any> = mapOf()): MetricsResponse

Tracks an event for analytics purposes.

Link copied to clipboard
open suspend fun updateSharePairStatus(type: PortalMpcShareType, status: PortalMpcShareStatus, sharePairIds: List<String>): Boolean

Updates the status of a share pair (either signing or backup).