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.prod.keyban.io",
appId: "your-app-id",
network: KeybanNetwork.EthereumAnvil,
});

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

See

KeybanAccount

Extends

  • KeybanClientBase

Constructors

Constructor

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.prod.keyban.io",
appId: "your-app-id",
network: KeybanNetwork.EthereumAnvil,
});

Overrides

KeybanClientBase.constructor

Properties

PropertyTypeDescriptionInherited from
apiUrlURLThe Keyban API URL, defaulting to "https://api.prod.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
networkKeybanNetworkThe blockchain used by Keyban.KeybanClientBase.network

Accessors

api

Get Signature

get api(): IKeybanApi;
Returns

IKeybanApi

Inherited from

KeybanClientBase.api

feesUnit

Get Signature

get feesUnit(): FeesUnit;

Retrieves the fee unit configuration based on the current network.

Maps supported networks to their fee unit details, including symbol and number of decimals. Supported configurations include:

  • EthereumAnvil & PolygonAmoy: symbol "gwei", decimals 9
  • StarknetDevnet, StarknetSepolia & StarknetMainnet: symbol "FRI", decimals 18
  • StellarQuickstart, StellarTestnet & StellarMainnet: symbol "stroop", decimals 7
Returns

FeesUnit

The fee unit configuration for the active network.

Inherited from

KeybanClientBase.feesUnit

nativeCurrency

Get Signature

get nativeCurrency(): NativeCurrency;

Retrieves the native currency details associated with the current network.

Returns an object that includes the native currency's name, symbol, and decimal precision for the active KeybanClientBase.network.

Returns

NativeCurrency

The native currency information for the current network.

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

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