Skip to main content

Class.KeybanClient

Main client for interacting with the Keyban API and associated services. This class provides methods to initialize accounts, retrieve balances, query NFTs, and interact with the Keyban blockchain.

Remarks

The KeybanClient serves as the primary interface for developers to interact with the Keyban ecosystem. It handles authentication, communication with the Keyban API, and provides utility methods for common tasks.

Example

// Initialize the client
const client = new KeybanClient({
apiUrl: "https://api.keyban.io",
appId: "your-app-id",
chain: KeybanChain.EthereumAnvil,
clientShareProvider: () => "your-client-shares-provider",
});

// Initialize an account
const account = await client.initialize();

See

KeybanAccount

Extends

  • KeybanClientBase

Constructors

new KeybanClient()

new KeybanClient(config: KeybanClientConfig): KeybanClient

Creates a new instance of KeybanClient.

Parameters

ParameterTypeDescription
configKeybanClientConfigThe configuration object to initialize the client.

Returns

KeybanClient

Throws

If the configuration is invalid.

Example

const client = new KeybanClient({
apiUrl: "https://api.keyban.io",
appId: "your-app-id",
clientShareProvider: () => "your-client-shares-provider",
chain: KeybanChain.EthereumAnvil,
});

Overrides

KeybanClientBase.constructor

Properties

PropertyTypeDescriptionInherited from
apiUrlURLThe Keyban API URL, defaulting to "https://api.keyban.io".KeybanClientBase.apiUrl
apolloClientApolloClient<NormalizedCacheObject>The Apollo GraphQL client used for making API requests.KeybanClientBase.apolloClient
appIdstringThe application ID used for authentication with the Keyban API.KeybanClientBase.appId
chainKeybanChainThe blockchain used by Keyban.KeybanClientBase.chain

Accessors

feesUnit

Get Signature

get feesUnit(): FeesUnit
Returns

FeesUnit

Inherited from

KeybanClientBase.feesUnit

nativeCurrency

Get Signature

get nativeCurrency(): NativeCurrency
Returns

NativeCurrency

Inherited from

KeybanClientBase.nativeCurrency

Methods

apiStatus()

apiStatus(): Promise<KeybanApiStatus>

Performs a health check on the Keyban API to determine its operational status.

Returns

Promise<KeybanApiStatus>

  • A promise resolving to the API status, either "operational" or "down".

Example

const status = await client.apiStatus();
console.log(`API Status: ${status}`);

Throws

Throws an error if the health check request fails.

See

KeybanApiStatus

Inherited from

KeybanClientBase.apiStatus

getUser()

getUser(): Promise<null | KeybanUser>

Returns

Promise<null | KeybanUser>

Inherited from

KeybanClientBase.getUser

initialize()

initialize(): Promise<KeybanAccount>

Initializes a KeybanAccount associated with the current client. This method sets up the account by retrieving or generating the client share, and prepares the account for transactions and other operations.

Returns

Promise<KeybanAccount>

  • A promise that resolves to an instance of KeybanAccount.

Throws

If initialization fails due to signing errors.

Example

const account = await client.initialize();
console.log(`Account address: ${account.address}`);

See

KeybanAccount

Overrides

KeybanClientBase.initialize

isAuthenticated()

isAuthenticated(): Promise<boolean>

Returns

Promise<boolean>

Inherited from

KeybanClientBase.isAuthenticated

login()

login(connection?: AuthConnection): Promise<void>

Initiates the login process by opening a popup window for user authentication.

Parameters

ParameterTypeDescription
connection?AuthConnectionOptional authentication connection details.

Returns

Promise<void>

  • A promise that resolves when the user is authenticated or the popup is closed.

Inherited from

KeybanClientBase.login

logout()

logout(): Promise<void>

Returns

Promise<void>

Inherited from

KeybanClientBase.logout